[Issue 8433] New: Compiler could warn on duplicate static if checks which can't branch

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jul 25 06:38:23 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=8433

           Summary: Compiler could warn on duplicate static if checks
                    which can't branch
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: andrej.mitrovich at gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2012-07-25 06:38:22 PDT ---
void main()
{
    enum int x = 1;

    static if (x == 1)
    {
        writeln("1");
    }
    else
    static if (x == 1)
    {
        writeln("2");
    }
}

Only the first write statement will be compiled in. I think the compiler could
help in these cases and produce a warning. There could be more complicated
cases like:

    static if (x != 1)
    {
    }
    else
    static if (x == 2)
    {
    }

Here again the second branch is never compiled.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list