www.digitalmars.com         C & C++   DMDScript  

D.gnu - Problem with multi-dimensional associative arrays?

reply Brian Palmer <d brian.codekitchen.net> writes:
This code works with DMD 1.010 for Windows, but fails with an ArrayBoundsError
on gdc 0.23, using dmd 1.007

void main() {
  int stuff[char[]][char[]];
  stuff["brian"]["pocket"] = 3;
}

It appears that GDC doesn't know how to handle multi-dimensional AAs.

(My environment: i686-apple-darwin8-gdc-4.0.1 (GCC) 4.0.1 (Apple Computer, Inc.
build 5363) (gdc 0.23, using dmd 1.007), I'm using a pre-compiled binary of GDC
downloaded from http://sourceforge.net/projects/gdcmac)
Apr 26 2007
parent reply Carlos Santander <csantander619 gmail.com> writes:
Brian Palmer escribió:
 This code works with DMD 1.010 for Windows, but fails with an ArrayBoundsError
on gdc 0.23, using dmd 1.007
 
 void main() {
   int stuff[char[]][char[]];
   stuff["brian"]["pocket"] = 3;
 }
 
 It appears that GDC doesn't know how to handle multi-dimensional AAs.
 
 (My environment: i686-apple-darwin8-gdc-4.0.1 (GCC) 4.0.1 (Apple Computer,
Inc. build 5363) (gdc 0.23, using dmd 1.007), I'm using a pre-compiled binary
of GDC downloaded from http://sourceforge.net/projects/gdcmac)
Try inserting this between those two lines: stuff["brian"] = null; I haven't tested it, but that's how I've always got stuff like that to work. -- Carlos Santander Bernal
Apr 26 2007
parent Brian Palmer <d brian.codekitchen.net> writes:
Carlos Santander Wrote:

 
 Try inserting this between those two lines:
 
 stuff["brian"] = null;
 
 I haven't tested it, but that's how I've always got stuff like that to work.
 
 -- 
 Carlos Santander Bernal
That worked, thank you! I was trying things like stuff["brian"] = new int[char[]]; which doesn't compile, I don't know why I didn't think of just setting it to null. Since my original example works with DMD on Windows, though, I think I better still file a bug report.
Apr 26 2007