[DMD 1.027] dynamic array out-of-bounds

Dave Dave_member at pathlink.com
Wed Feb 20 15:54:34 PST 2008


Don't throw the -release switch and you should see the ABE.

"Keir" <spam at no.grok.ath.cx> wrote in message 
news:Xns9A4A65F8592BCpantherkeir at 65.204.18.192...
>I expected the following to blow up with horrid results, but it seems to
> truck along just fine.
>
> //{BeginCode}//////////////////////////////////////////////////
> import std.stdio;
>
> void main()
>  {
>  int[] arr;
>  arr.length = (3*6);
>
>  arr[3] = 3;
>  arr[4] = 4;
>  arr[5] = 5;
>  arr[10] = 10;
>  arr[18] = 18;  // expected runtime arraybounds error here
>  arr[19] = 19;
>  arr[20] = 20;
>  arr[21] = 21;
>  arr[22] = 22;
>  arr[30] = 30;
>
>  // should overwrite ~some~thing important, yes?
>  for ( int i;i<arr.length*10;i++)
>    arr[i]=i+1;
>
>  // expected arr[18] to throw the arraybounds error
>  for ( int i;i<31*5;i++)
>    writefln("%s [%s]",i,arr[i]);
>  } 



More information about the Digitalmars-d-bugs mailing list