Is the following well defined and allowed?
ag0aep6g
anonymous at example.com
Thu Mar 1 20:24:38 UTC 2018
On Thursday, 1 March 2018 at 20:14:07 UTC, Steven Schveighoffer
wrote:
> dmd -version=dosafe -noboundscheck -run testarrayoverlap.d =>
> no error, undefined behavior
> dmd -run testarrayoverlap.d => error
>
> @safe has nothing to do with it.
@safe has everything to do with. @safe guarantees that there's no
undefined behavior. If you can trigger UB in @safe code, that's a
bug. The guarantee must hold whether asserts are enabled or not.
-noboundscheck does not just disable asserts, it undermines
@safe, rendering it meaningless.
For just disabling asserts (without affecting @safe), there's
-release. With your same code, `dmd -release` => UB, but `dmd
-release -version=dosafe` => Error.
More information about the Digitalmars-d
mailing list