Bug 22297 – Behavior of minElement and maxElement with empty range is undocumented

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-09-10T16:20:22Z
Last change time
2021-09-10T17:57:52Z
Keywords
pull
Assigned to
No Owner
Creator
Paul Backus

Comments

Comment #0 by snarwin+bugzilla — 2021-09-10T16:20:22Z
The documentation for minElement and maxElement does not specify what happens when either function is called with an empty range as its argument. Experimentation reveals that what happens is an assertion failure, which terminates the program: --- import std.algorithm.searching; void main() { int[] emptyArr; auto min = minElement(emptyArr); // AssertError: r is an empty range } --- This behavior should be documented.
Comment #1 by dlang-bot — 2021-09-10T16:52:12Z
@pbackus created dlang/phobos pull request #8238 "Fix Issue 22297 - Behavior of minElement and maxElement with empty ra…" fixing this issue: - Fix Issue 22297 - Behavior of minElement and maxElement with empty range is undocumented https://github.com/dlang/phobos/pull/8238
Comment #2 by dlang-bot — 2021-09-10T17:57:52Z
dlang/phobos pull request #8238 "Fix Issue 22297 - Behavior of minElement and maxElement with empty ra…" was merged into master: - f252771e7520352c29cf230023b3a6475ee5e1e1 by Paul Backus: Fix Issue 22297 - Behavior of minElement and maxElement with empty range is undocumented https://github.com/dlang/phobos/pull/8238