Bug 328 – Access violation when setting length of an array of fairly large static arrays

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2006-09-06T14:58:00Z
Last change time
2014-02-15T13:21:23Z
Keywords
wrong-code
Assigned to
bugzilla
Creator
smjg

Comments

Comment #0 by smjg — 2006-09-06T14:58:30Z
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.
Comment #1 by bugzilla — 2006-09-19T15:29:34Z
Fixed in DMC 0.167.