Bug 10696 – Show array bounds in Range violation exception messages

Status
RESOLVED
Resolution
DUPLICATE
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-07-22T10:26:00Z
Last change time
2014-04-25T18:41:27Z
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2013-07-22T10:26:14Z
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'
Comment #1 by andrej.mitrovich — 2014-04-25T18:41:27Z
*** This issue has been marked as a duplicate of issue 6513 ***