[Issue 10696] New: Show array bounds in Range violation exception messages

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jul 22 10:26:15 PDT 2013


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

           Summary: Show array bounds in Range violation exception
                    messages
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: bearophile_hugs at eml.cc


--- Comment #0 from bearophile_hugs at eml.cc 2013-07-22 10:26:14 PDT ---
void main(string[] args) {
    auto a = new int[5];
    auto x = a[args.length + 10];
}


DMD 2.064alpha gives me at runtime:

core.exception.RangeError at test(3): Range violation


But I'd like an error like:

core.exception.RangeError at test(3): Range violation with index '11' outside the
[0 .. 5] bounds


If it's not convenient to write that, then a simpler error message can be:

core.exception.RangeError at test(3): Range violation with index '11'

Such printed range values are very useful during debugging.


If possible I'd like such error messages to show signed values before they get
converted to a size_t, to make the messages more easy to read:


void main() {
    auto a = new int[5];
    int i = -10;
    auto x = a[i];
}

===>
core.exception.RangeError at test(3): Range violation with index '-10'

-- 
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