Should unreachable code be considered an error?

Stewart Gordon smjg_1998 at yahoo.com
Tue Oct 11 17:27:50 PDT 2011


On 02/10/2011 22:41, Walter Bright wrote:
> On 10/2/2011 2:18 PM, Stewart Gordon wrote:
>> Simply because we can't rely on every compiler to perform even the most basic
>> cases of DCE?
>
> Consider:
>
> if (a) { ... code ... }
>
> Sometimes, when debugging, I'll do:
>
> if (0 && a) { ... code ... }
<snip>

I was talking about cases of DCE that are even more basic than this, such as:

void qwert() {
     return;
     yuiop();
}

void asdfg() {
     if (hjkl) {
         return zxcvb;
     } else {
         return nm;
     }
     qaz();
}

These are exactly what I mean by no arrow leading to a given statement.  In your examples, 
OTOH, the arrow exists - it will just never be followed.

Stewart.


More information about the Digitalmars-d mailing list