https://issues.dlang.org/show_bug.cgi?id=17650
--- Comment #7 from Jon Degenhardt <[email protected]> --- (In reply to ZombineDev from comment #6) > The error doesn't make sense to me. @safe adds bounds checks where there are > none only when building with -release. I.e. if we're not building with > -release, there shouldn't be any change in behavior - bounds checking should > already be present (-boundscheck defaults to 'on' in that case). Am I > missing something? There was already an existing range violation, one that didn't have a unit test in the std.getopt module. Adding @safe to the function turned on bounds checking in debug mode. I had a unit test in my own code (not std.geopt) that triggered the out-of-bounds case. This unit test didn't get run until I actually ran my own unit tests with the new code. The out-of-bounds case occurs when there is an command line argument that is a single dash. e.g. $ myprogram -x a # okay $ myprogram -x - # out-of-bounds In the single dash case there's an attempt to access one character past it. Kind of understandable there wasn't a unit test for this originally. If you want to see the sequence that led to adding @safe read https://github.com/dlang/phobos/pull/5347. --
