www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 328] New: Access violation when setting length of an array of fairly large static arrays

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


-- 
Sep 06 2006
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=328


bugzilla digitalmars.com changed:

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




------- Comment #1 from bugzilla digitalmars.com  2006-09-19 15:29 -------
Fixed in DMC 0.167.


-- 
Sep 19 2006