[Issue 5870] New: Debug code in SortedRange assumes it can always print the range

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Apr 22 06:27:27 PDT 2011


http://d.puremagic.com/issues/show_bug.cgi?id=5870

           Summary: Debug code in SortedRange assumes it can always print
                    the range
           Product: D
           Version: D2
          Platform: Other
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: schveiguy at yahoo.com


--- Comment #0 from Steven Schveighoffer <schveiguy at yahoo.com> 2011-04-22 06:23:47 PDT ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list