Overflows in Phobos

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Tue Jul 26 14:56:58 PDT 2016


On 7/26/2016 7:28 AM, 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.
>
> Your patch is just telling the optimizer that there is actually no security
> hole, even when that is not true. It is a bad idea to conflate assert and assume.

What the assert(0) actually does is insert a HALT instruction, even when 
-release is used. The spec is poorly worded.


More information about the Digitalmars-d mailing list