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

           Summary: False accusation of NULL-ness after ingenious control
                    flow
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: [email protected]
        ReportedBy: [email protected]
                CC: [email protected], [email protected],
                    [email protected]


$ cat test.cc
#include <stdio.h>
int main() {
    puts(0);  // Generates the first line, containing "(null)"
    if (const char* msg = "") {
        goto label;
    } else
    label:
        puts(msg);  // Generates the second line, blank
}
$ clang++ test.cc -o test -Wall
test.cc:8:14: warning: 'msg' is always NULL in this context
        puts(msg);
             ^
1 warning generated.
$ ./test
(null)

$ 


Note that msg will always be non-NULL (""), so the if branch will be taken. It
then jumps into the else branch and uses msg, so msg will never be NULL,
contrary to the warning.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- 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