On Tuesday, 26 July 2016 at 14:28:48 UTC, Timon Gehr wrote:
According to the language documentation, the patch does not fix
the problem.
https://dlang.org/spec/expression.html#AssertExpression
"The expression assert(0) is a special case; it signifies that
it is unreachable code. [...] The optimization and code
generation phases of compilation may assume that it is
unreachable code."
One way the optimizer can use the assumption is for optimizing
away the overflow check.
This is not true. The spec is unclear, but what makes assert(0)
special is that the compiler is not allowed to remove it from the
program, not at any optimization level (other asserts can and
will be removed by the compiler, see `-release`).
The compiler can assume it is unreachable code, but it has to
keep it, so:
```
if (foo()) {
// compiler can assume _almost_ zero probability for taking
this branch
assert(0);
}
```