The case of -debug -O and: is breaking pure/@nogc/nothrow/@safe UB under -debug?

Guillaume Piolat first.last at gmail.com
Wed Apr 18 13:15:08 UTC 2018


The D specification says:

"A ConditionalStatement that has a DebugCondition is called a 
DebugStatement. DebugStatements have relaxed semantic checks in 
that pure, @nogc, nothrow and @safe checks are not done. Neither 
do DebugStatements influence the inference of pure, @nogc, 
nothrow and @safe attributes."


So it seems under a debug clause you don't have to conform to 
pure/@nogc/nothrow/@safe.

The immediate question that follow is:

"Is breaking pure/@nogc/nothrow/@safe Undefined Behaviour (UB) in 
a DebugStatement?"

Would the optimizer -O breaks code that breaks such by virtue of 
being -debug?

If no (not UB), doesn't this guarantees that no optimizations 
will ever be performed thanks to pure/@nogc/nothrow/@safe?


More information about the Digitalmars-d-learn mailing list