http://llvm.org/bugs/show_bug.cgi?id=18429

            Bug ID: 18429
           Summary: false-negative for -Wunreachable-code
           Product: clang
           Version: 3.3
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    Classification: Unclassified

Created attachment 11855
  --> http://llvm.org/bugs/attachment.cgi?id=11855&action=edit
missing -Wunreachable-code warning

-Wunreachable-code warning should be reported in cases like this:

    unsigned int n = 0;
    if (n == 0)
        return 1;
    else
        return 2; // dead code

Note that if I manually constant-fold n to 0, then -Wunreachable-code is
reported:

    if (0)
        return 1;
    else
        return 2; // dead code

Also note that with "-O1" dead code is actually eliminated.

See full example in attachment. Compiles without warnings:
$ clang -O1 -Wunreachable-code wunreachable_code_false_negative.c 
$

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to