[Issue 22297] New: Behavior of minElement and maxElement with empty range is undocumented
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Sep 10 16:20:22 UTC 2021
https://issues.dlang.org/show_bug.cgi?id=22297
Issue ID: 22297
Summary: Behavior of minElement and maxElement with empty range
is undocumented
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P1
Component: phobos
Assignee: nobody at puremagic.com
Reporter: snarwin+bugzilla at gmail.com
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.
--
More information about the Digitalmars-d-bugs
mailing list