[LLVMbugs] [Bug 2304] New: CHECKER: false positive on uninitialized warning

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Sat May 10 01:39:07 PDT 2008


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

           Summary: CHECKER: false positive on uninitialized warning
           Product: clang
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Semantic Analyzer
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: edwintorok at gmail.com
                CC: llvmbugs at cs.uiuc.edu


Using SVN r4294967285:

$ ~/llvm-svn/llvm/tools/clang/utils/ccc-analyzer xtest.c -c
xtest.c
ANALYZE: xtest.c foo
xtest.c:10:2: warning: [CHECKER] Branch condition evaluates to an uninitialized
value.
        if(pt->partno == 1 || !found) {
        ^                     ~~~~~~
ANALYZE: xtest.c bar
1 diagnostic generated.

$ cat xtest.c
struct x {
        int partno;
};
int foo(struct x *pt)
{
        int found;
        if(pt->partno != 1) {
                found = 0;
        }
        if(pt->partno == 1 || !found) {
                return 1;
        }
        return 0;
}

int bar(int partno)
{
        int found;
        if(partno != 1) {
                found = 0;
        }
        if(partno == 1 || !found) {
                return 1;
        }
        return 0;
}

The HTML output produced says that the branch if(pt->partno...) is untaken.
Notice that if I use a struct it gives a warning, if I don't use the struct it
doesn't give a warning. found is not used uninitialized, because when 
partno is 1 the !found condition is not evaluated anymore.
Also if partno was 1 on the first if, it still is that on the 2nd one.


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