Bug 1898 – infinite loop when allocate an array of AA

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Linux
Creation time
2008-03-08T14:23:00Z
Last change time
2015-06-09T01:14:37Z
Keywords
wrong-code
Assigned to
bugzilla
Creator
someanon

Attachments

IDFilenameSummaryContent-TypeSize
232mapbug.dinfinite loop, allocate an array of AAtext/plain228

Comments

Comment #0 by someanon — 2008-03-08T14:23:42Z
How to allocate an array of AA? 1) I tried two ways (new, and setting array length), in both cases the code compiles, but the executable seems run into infinite loop, and never finish. 2) how to new an AA? what's the syntax? http://www.digitalmars.com/pnews/read.php?server=news.digitalmars.com&group=digitalmars.D&artnum=67463 http://www.digitalmars.com/pnews/read.php?server=news.digitalmars.com&group=digitalmars.D&artnum=67466 $ cat mapbug.d void allocAA() { int[int][] maps; maps = new int[int][3]; maps.length = 3; int[int]* mapsp; //mapsp = new int[int]; // this line need size of rightmost array, not type int } int main() { allocAA(); return 0; }
Comment #1 by someanon — 2008-03-08T14:25:13Z
Created attachment 232 infinite loop, allocate an array of AA
Comment #2 by smjg — 2008-11-20T13:28:48Z
As for your second question, I'm not sure that there's a general way. But mapsp = (new int[int][1]).ptr; should work once the underlying bug is fixed. Meanwhile, a workaround is int[int][1] mapsa; mapsp = mapsa.dup.ptr; But since the main bug you're reporting has already been reported and voted on, I'm marking this as a dupe. *** This bug has been marked as a duplicate of 929 ***