Should unreachable code be considered an error?

Stewart Gordon smjg_1998 at yahoo.com
Fri Aug 19 17:42:56 PDT 2011


On 18/08/2011 13:19, Bernard Helyer wrote:
<snip>
> 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).

So essentially you're looking to catch cases where, if you consider the function as a flow 
chart, there is no chain of arrows from the start of the function to the statement in 
question.  That should be straightforward.  But you're not worrying about catching cases 
where some arrow would never be followed.  Have I got that right?

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

Not sure whether it should be allowed to be used e.g. to prevent execution of code that is 
under construction.

Stewart.


More information about the Digitalmars-d mailing list