Bug 765 – ArrayBoundsError when assigning slice of pointer
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Linux
Creation time
2006-12-28T20:27:00Z
Last change time
2014-02-15T13:21:12Z
Keywords
wrong-code
Assigned to
bugzilla
Creator
fvbommel
Comments
Comment #0 by fvbommel — 2006-12-28T20:27:52Z
void main() {
uint* where = (new uint[](5)).ptr;
// either of these lines will throw an ArrayBoundsError
// without even accessing an array variable :( (just a pointer)
where[0 .. 5] = 1;
where[0 .. 0] = 0; // not even actually accessing anything!
}
-----
Error: ArrayBoundsError test.d(6)
This did not happen in DMD 0.173
The only reason I can think of for bounds checks to even be made on pointer slices are:
* check (upper >= lower)
* check (upper * T.sizeof <= 2**32) (on 32-bit machine) to make sure stuff fits into memory...
Both of these conditions are definitely satisfied here, so I don't see any legitimate reason for this to happen...