Error: array dimension overflow

Jarrett Billingsley kb3ctd2 at yahoo.com
Fri Mar 21 05:50:16 PDT 2008


"Brian Hay" <bhay at construct3d.com> wrote in message 
news:frviab$126$1 at digitalmars.com...
> Newbie Q:
>
> During compilation I'm getting the error: "array dimension overflow" but 
> it doesn't provide any information as to where (module and line number) 
> the error might be, so I'm at a loss. Other errors seem to provide such 
> information.
>
> Any ideas?

Hee hee hee.

static int[] x = [-1: 1];

There's some kind of funky logic in the compiler which for some reason does 
not detect negative initialization indices, but rather does something like

currentLength = index.toInt();
currentLength++;

if(currentLength == 0)
    error("array dimension overflow");

It's to detect index overflow, but it's easily fooled by using a negative 
index, which it should really detect anyway.

Are you using, maybe, 0xFFFF_FFFF anywhere as an array initializer index? 
Also, are you getting an "array initializers as expressions are not allowed" 
error at the same time by any chance? 




More information about the Digitalmars-d-learn mailing list