AA of AAs -- ArrayBoundsError

Matti Niemenmaa see_signature at for.real.address
Mon Oct 29 08:10:03 PDT 2007


nobody wrote:
> The following code results in an ArrayBoundsError with my v1.015 compiler:
> 
>   typedef size_t IA;
>   typedef size_t IB;
>   typedef uint V;
> 
>   void main(char[][] args)
>   {
>     V[IB] [IA] test;
>     test[cast(IA) test.length]
>       [cast(IB) test[cast(IA) test.length].length] =
>     cast(V) (test.length * test[cast(IA) test.length].length);
>   }

The problem is on the right hand side of the assignment, namely on the access
test[cast(IA) test.length]. The AA test is empty, so retrieving any element will
fail with an ArrayBoundsError.

Assign test[1][1] = something; first, and then it will work. (1, because
test.length will be 1 after the assignment.)

-- 
E-mail address: matti.niemenmaa+news, domain is iki (DOT) fi


More information about the Digitalmars-d-bugs mailing list