[LLVMbugs] [Bug 18429] New: false-negative for -Wunreachable-code

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Jan 9 08:51:15 PST 2014


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: unassignedclangbugs at nondot.org
          Reporter: skvadrik at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140109/d1f64dab/attachment.html>


More information about the llvm-bugs mailing list