assume, assert, enforce, @safe

Timon Gehr via Digitalmars-d digitalmars-d at puremagic.com
Fri Aug 1 10:43:26 PDT 2014


On 08/01/2014 07:19 PM, Sebastiaan Koppe wrote:
> If assertions are disabled in release builds, and you specifically
> instruct the compiler to build one, are you not assuming that the
> assertions will hold?
> ...

It would often be foolish to simply assume so, and disabling of the 
assertions can be motivated differently (and not all motivations are 
valid; _they don't need to be_.)

> Then what is wrong with extending those assumptions to the optimizer?
> ...

To appreciate this better, simply imagine you are the guy who needs to 
track down the bug (which you don't reproduce locally, there can be many 
reasons for that) but who is not responsible for it.

> Unless the assertions trigger in debug build, you will not end up with
> bugs in the release.

The debug and the release build may be subjected to different input and 
hence traverse different traces of abstract states. It is not valid to 
say that an assertion will never fail just because it hasn't failed yet.


More information about the Digitalmars-d mailing list