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]);
    }
}

  • forgetting -bett... areYouSureAboutThat via Digitalmars-d-learn

Reply via email to