Bug 5870 – Debug code in SortedRange assumes it can always print the range
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
Other
OS
All
Creation time
2011-04-22T06:23:00Z
Last change time
2014-03-19T21:57:34Z
Assigned to
nobody
Creator
schveiguy
Comments
Comment #0 by schveiguy — 2011-04-22T06:23:47Z
In SortedRange, there is a debug clause in the constructor which checks the sortedness of the input.
The final assert assumes it can print the range if the sortedness isn't true. However, a range of types that do not define toString will fail to compile, even if the range can be sorted.
For example:
interface I {}
auto sr = SortedRange!(I[]);
The fix is simple, do the assert without printing the range (from range.d line 5400 in dmd 2.052):
- assert(isSorted!pred(st), text(st));
+ static if(is(typeof(text(st))))
+ assert(isSorted!pred(st), text(st));
+ else
+ assert(isSorted!pred(st));
This is another case of bug 4901, but I didn't see it because I normally don't compile with -debug enabled.
See http://www.dsource.org/projects/dcollections/ticket/13 for the error listing.
Comment #1 by lt.infiltrator — 2014-03-19T17:33:09Z