Strange Runtime Error - Static Arrays

Zachary Lund admin at computerquip.com
Sun Jan 8 15:34:45 PST 2012


On 01/08/2012 05:33 PM, Zachary Lund wrote:
> Someone brought an example that I thought was rather strange an
> preventable in the IRC this evening. Take this example:
>
> int[3] bob = [ 1, 2, 3];
>
> The above will compile fine and the program may even run fine up until
> the above statement. When the above statement is executed, an
> exceptional error is given:
>
> object.Exception at src/rt/arraycat.d(31): lengths don't match for array copy
> ----------------
> ./main() [0x8049ec3]
> ./main() [0x804cbd0]
> ./main() [0x804c875]
> ./main() [0x804cc17]
> ./main() [0x804c875]
> ./main() [0x804c824]
> /lib/libc.so.6(__libc_start_main+0xf3) [0xb764d483]
> ----------------
>
> Couldn't this be prevented at compile time?

Er, wrong line given...

int[4] bob = [ 1, 2, 3 ];


More information about the Digitalmars-d mailing list