Should unreachable code be considered an error?

Walter Bright newshound2 at digitalmars.com
Sun Oct 2 14:41:28 PDT 2011


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 ... }

to temporarily disable it. Should that be made illegal? If so, what about:

    const X = 0;
    if (X && a) { ... code ... }

Illegal too? What about:

    bool foo() { ... }
    if (foo() && a) { ... code ... }

where foo() may be evaluatable at compile time. How far should this go?


More information about the Digitalmars-d mailing list