Should unreachable code be considered an error?

Bernard Helyer b.helyer at gmail.com
Thu Aug 18 05:19:41 PDT 2011


On Thu, 18 Aug 2011 14:14:08 +0200, Timon Gehr wrote:

>The trouble with making dead code an error in general is that the
>compiler is not able to detect dead code in most cases.

I'm talking about the unambiguous cases, the ones where a basic block has 
no parents (i.e. there is no way to enter that code block).

> Also, since the compiler is allowed to assume that any assert(0); is
> dead code, assert(0) would always be a compile time error. =)

No, only if statements followed the assert(0) (which marks the control 
flow block as terminated, just like return).


More information about the Digitalmars-d mailing list