[LLVMbugs] [Bug 9161] New: Clang -Wall too noisy with uninitialized variables in common idiom

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Feb 7 08:27:41 PST 2011


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

           Summary: Clang -Wall too noisy with uninitialized variables in
                    common idiom
           Product: new-bugs
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: stark at mit.edu
                CC: llvmbugs at cs.uiuc.edu


stark at raving:~/src$ clang --version
clang version 2.9 (trunk 125005)
Target: x86_64-unknown-linux-gnu
Thread model: posix

The attached file demonstrates a common programming idiom where a variable is
initialized by passing a reference to it to a function. Clang assumes the
function might not initialize the variable when in fact the programmer knows it
will.

I realize neither option is palatable here but if clang can't prove that the
function has a code path that appears to fail to initialize the variable then
it's better off not printing spurious warnings. 

$ clang -Wall test-llvm-uninitialized.c 
test-llvm-uninitialized.c:14:10: warning: variable 'uninitialized' is possibly
uninitialized when used here [-Wuninitialized]
                return(uninitialized);
                       ^~~~~~~~~~~~~
test-llvm-uninitialized.c:7:2: note: variable 'uninitialized' is declared here
        int uninitialized;
        ^
test-llvm-uninitialized.c:7:19: note: add initialization to silence this
warning
        int uninitialized;
                         ^
                          = 0
1 warning generated.

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



More information about the llvm-bugs mailing list