View mode: basic / threaded / horizontal-split · Log in · Help
March 08, 2008
[Issue 1898] New: infinite loop when allocate an array of AA
http://d.puremagic.com/issues/show_bug.cgi?id=1898

          Summary: infinite loop when allocate an array of AA
          Product: D
          Version: 2.012
         Platform: PC
       OS/Version: Linux
           Status: NEW
         Severity: normal
         Priority: P2
        Component: DMD
       AssignedTo: bugzilla@digitalmars.com
       ReportedBy: someanon@yahoo.com


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;
}


--
March 08, 2008
[Issue 1898] infinite loop when allocate an array of AA
http://d.puremagic.com/issues/show_bug.cgi?id=1898





------- Comment #1 from someanon@yahoo.com  2008-03-08 14:25 -------
Created an attachment (id=232)
--> (http://d.puremagic.com/issues/attachment.cgi?id=232&action=view)
infinite loop, allocate an array of AA


--
November 20, 2008
[Issue 1898] infinite loop when allocate an array of AA
http://d.puremagic.com/issues/show_bug.cgi?id=1898


smjg@iname.com changed:

          What    |Removed                     |Added
----------------------------------------------------------------------------
                CC|                            |smjg@iname.com
            Status|NEW                         |RESOLVED
          Keywords|                            |wrong-code
        Resolution|                            |DUPLICATE




------- Comment #2 from smjg@iname.com  2008-11-20 13:28 -------
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 ***


--
Top | Discussion index | About this forum | D home