www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10696] New: Show array bounds in Range violation exception messages

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 puremagic.com
        ReportedBy: bearophile_hugs eml.cc



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 test(3): Range violation


But I'd like an error like:

core.exception.RangeError 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 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 test(3): Range violation with index '-10'

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