1898 – infinite loop when allocate an array of AA

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 1898 - infinite loop when allocate an array of AA
Summary: infinite loop when allocate an array of AA
Status: RESOLVED DUPLICATE of issue 929
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Linux
: P2 normal
Assignee: Walter Bright
URL:
Keywords: wrong-code
Depends on:
Blocks:
Reported: 2008年03月08日 14:23 UTC by sa
Modified: 2015年06月09日 01:14 UTC (History)
1 user (show)

See Also:


Attachments
infinite loop, allocate an array of AA (228 bytes, text/plain)
2008年03月08日 14:25 UTC, sa
Details
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description sa 2008年03月08日 14:23:42 UTC
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 sa 2008年03月08日 14:25:13 UTC
Created attachment 232 [details] 
infinite loop, allocate an array of AA
Comment 2 Stewart Gordon 2008年11月20日 13:28:48 UTC
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 ***


AltStyle によって変換されたページ (->オリジナル) /