assert and enforce both compiled out with -release
kdevel
kdevel at vogtner.de
Sat Jan 27 13:52:47 UTC 2018
https://dlang.org/phobos/std_exception.html#enforce states:
| Also, do not use enforce inside of contracts (i.e. inside of in
and out blocks
| and invariants), because they will be compiled out when
compiling with -release.
| Use assert in contracts.
But assert is also ignored in release mode:
ass.d
---
void foo (int i)
in {
assert (i < 0);
}
body {
}
void main ()
{
foo (1);
}
---
$ dmd ass
$ ./ass
core.exception.AssertError at ass.d(3): Assertion failure
----------------
??:? _d_assertp [0x42a065]
??:? void ass.foo(int) [0x429f9d]
??:? _Dmain [0x429fad]
$ dmd -release ass
$ ./ass
[nothing]
More information about the Digitalmars-d-learn
mailing list