What's the deal with -boundscheck?
Walter Bright via Digitalmars-d
digitalmars-d at puremagic.com
Sun Apr 5 22:15:43 PDT 2015
On 4/5/2015 7:13 PM, Andrei Alexandrescu wrote:
> I've spent the better part of yesterday and today debugging a complex matter
> involving pointers, reduced to this:
>
> ../dmd/src/dmd -conf= -I../druntime/import -w -dip25 -m64 -O -release -main
> -unittest generated/osx/release/64/libphobos2.a -defaultlib= -debuglib= -L-lcurl
> -run std/experimental/allocator/kernighan_ritchie.d
>
> In this configuration, surprisingly there's no bounds checks inserted. I need to
> explicitly add -boundcheck=on.
>
> Why the change? I've fought tooth and nail for keeping bounds checking in
> release mode and with optimizations on, precisely because I think it's a check
> that's valuable enough to warrant explicit disabling.
>
> Could someone please explain. This is a shame.
I read the code to figure out what was happening.
At some point, -release was changed so that bounds checking was turned off for
all but @safe code. A new switch was added, -boundscheck=[on|safeonly|off]. It
took me a while to find it at:
http://dlang.org/dmd-linux.html
because whoever added it didn't realize that the list was alphabetized and stuck
it in there after -map.
I don't know why the change was made.
More information about the Digitalmars-d
mailing list