[Issue 328] New: Access violation when setting length of an array of fairly large static arrays

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Sep 6 12:58:31 PDT 2006


http://d.puremagic.com/issues/show_bug.cgi?id=328

           Summary: Access violation when setting length of an array of
                    fairly large static arrays
           Product: D
           Version: 0.165
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: wrong-code
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: smjg at iname.com


This code compiles, but produces an access violation:

----------
void main(char[][] args) {
    uint[152][] data;

    data.length = 1;
}
----------

Other types show similar problems.  Tests with int[n], short[n] and byte[n]
continue to show that it will work as long as the size of the static array is
no greater than 604 bytes.  The value to which the dynamic array length is set
(except for zero) appears to make no difference.

Strangely, adding writefln statements either side of the data.length assignment
increases the length that'll work to 620 bytes.

If there is more than one dimension of static array, e.g.

    byte[303][2][] data;

then the threshold seems to be the same.


I cannot reproduce a similar problem with a dynamic array of struct rather than
a dynamic array of static array.  However, the problem does occur in the case
that is dynamic array of static array of struct.  For example, this code AVs:

----------
struct Qwert {
    byte[603] yuiop;
}

void main(char[][] args) {
    Qwert[2][] asdfg;

    asdfg.length = 10;
}
----------

but doesn't AV for any smaller byte[n] length.  If Qwert[3][] is used instead,
then a struct length of 302 bytes is sufficient for an AV.


-- 




More information about the Digitalmars-d-bugs mailing list