Bug 6883 – Array static bounds tests with $ too

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-11-02T17:12:00Z
Last change time
2012-12-13T08:47:58Z
Keywords
diagnostic, pull
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2011-11-02T17:12:14Z
D2 code: void main() { int[5] x; x[x.length] = 1; enum size_t n = 2; x[x.length + n] = 2; } DMD 2.056 gives at compile-time: test.d(3): Error: array index 5 is out of bounds x[0 .. 5] test.d(5): Error: array index 7 is out of bounds x[0 .. 5] I'd like this similar program to give similar compile-time errors (with DMD 2.056 it gives no compile errors, and gives just run-time errors in debug mode): void main() { int[5] x; x[$] = 1; enum size_t n = 2; x[$ + n] = 2; }
Comment #1 by bearophile_hugs — 2011-11-02T17:16:56Z
See also bug 6884
Comment #2 by bearophile_hugs — 2012-12-13T03:10:46Z
Instead of an enhancement request this now becomes a bug report, after a discussion with Walter: http://forum.dlang.org/thread/[email protected]?page=2#post-kacc35:24coi:241:40digitalmars.com
Comment #3 by k.hara.pg — 2012-12-13T05:52:40Z
Comment #4 by github-bugzilla — 2012-12-13T06:45:23Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/ca8ddac03a5e04f28290cb4ecac6147de312a582 fix Issue 6883 - Array static bounds tests with $ too https://github.com/D-Programming-Language/dmd/commit/b7443d1e52014ae36a6d556f5c71b14eb3148401 Merge pull request #1372 from 9rnsr/fix6883 Issue 6883 - Array static bounds tests with $ too