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
Comment #2 by github-bugzilla — 2014-03-19T21:52:12Z
Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/ee2d46263bedd6b58663fa710690f5339d7b5ca0 Issue 5870 - Debug code in SortedRange assumes it can always print the range https://github.com/D-Programming-Language/phobos/commit/2644eb9081f778ae20fdc6473d868b879c83208a Merge pull request #2028 from Infiltrator/patch-1 Issue 5870 - Debug code in SortedRange assumes it can always print the ...