D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 5870 - Debug code in SortedRange assumes it can always print the range
Summary: Debug code in SortedRange assumes it can always print the range
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: Other All
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-22 06:23 UTC by Steven Schveighoffer
Modified: 2014-03-19 21:57 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Steven Schveighoffer 2011-04-22 06:23:47 UTC
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 2 github-bugzilla 2014-03-19 21:52:12 UTC
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 ...