forgetting -betterC means no runtime bounds checking?
areYouSureAboutThat
areYouSureAboutThat at gmail.com
Thu Jan 5 09:10:00 UTC 2023
I was playing around with betterC, when I discovered, that if i
accidently forget to provide -betterC to the compiler, it will
still compile this, but, there will be no runtime bounds checking
occuring.
My question is: why is there no bounds checking occurring if I
forget to use -betterC?
module test;
extern(C) void main()
{
import core.stdc.stdio : printf;
int[5] arr = [ 0, 1, 2, 3, 4];
for (int i = 0; i < 10; i++) // oops!
{
printf("%d\n", arr[i]);
}
}
More information about the Digitalmars-d-learn
mailing list