[Issue 765] New: ArrayBoundsError when assigning slice of pointer
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Dec 28 18:27:53 PST 2006
http://d.puremagic.com/issues/show_bug.cgi?id=765
Summary: ArrayBoundsError when assigning slice of pointer
Product: D
Version: 0.178
Platform: PC
OS/Version: Linux
Status: NEW
Keywords: wrong-code
Severity: normal
Priority: P2
Component: DMD
AssignedTo: bugzilla at digitalmars.com
ReportedBy: fvbommel at wxs.nl
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...
--
More information about the Digitalmars-d-bugs
mailing list