March 08, 2008

           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

How to allocate an array of AA?

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.

how to new an AA? what's the syntax?

$ 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 main() {

  return 0;


March 08, 2008

------- Comment #1 from  2008-03-08 14:25 -------
Created an attachment (id=232)
 --> (
infinite loop, allocate an array of AA


November 20, 2008 changed:

           What    |Removed                     |Added
                 CC|                            |
             Status|NEW                         |RESOLVED
           Keywords|                            |wrong-code
         Resolution|                            |DUPLICATE

------- Comment #2 from  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