assert and enforce both compiled out with -release
Ali Çehreli
acehreli at yahoo.com
Sat Jan 27 14:31:13 UTC 2018
On 01/27/2018 05:52 AM, kdevel wrote:
> 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:
The documentation is not clear. "they will be compiled out" means
"contracts are compiled out". So, an enforce() would disappear if it's
inside such a block, which should not be what the programmer wants for
an enforce().
Fixed it through the "Improve this page" link on that Phobos page:
https://github.com/dlang/phobos/blob/master/std/exception.d
Ali
More information about the Digitalmars-d-learn
mailing list