digitalmars.D.bugs - [DMD 1.027] dynamic array out-of-bounds
- Keir (25/25) Feb 20 2008 I expected the following to blow up with horrid results, but it seems to...
- Bill Baxter (5/35) Feb 20 2008 Did you compile with -debug?
- Dave (3/28) Feb 20 2008 Don't throw the -release switch and you should see the ABE.
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]); }
Feb 20 2008
Keir wrote: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]); }Did you compile with -debug? I don't recall exactly, but I think that may be required to turn on array bounds checking. --bb
Feb 20 2008
Don't throw the -release switch and you should see the ABE. "Keir" <spam no.grok.ath.cx> wrote in message news:Xns9A4A65F8592BCpantherkeir 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]); }
Feb 20 2008