www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 765] New: ArrayBoundsError when assigning slice of pointer

reply d-bugmail puremagic.com writes:
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 digitalmars.com
        ReportedBy: fvbommel 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...


-- 
Dec 28 2006
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=765






Added to DStress as
http://dstress.kuehne.cn/run/n/new_28_A.d
http://dstress.kuehne.cn/run/n/new_28_B.d
http://dstress.kuehne.cn/run/n/new_28_C.d
http://dstress.kuehne.cn/run/n/new_28_D.d


-- 
Dec 31 2006
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=765


bugzilla digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED





Fixed DMD 1.00


-- 
Jan 03 2007