[LLVMbugs] [Bug 9282] New: [C++] False positive about garbage value with structs.

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Feb 21 13:51:16 PST 2011


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

           Summary: [C++] False positive about garbage value with structs.
           Product: clang
           Version: trunk
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Static Analyzer
        AssignedTo: kremenek at apple.com
        ReportedBy: devlists at shadowlab.org
                CC: llvmbugs at cs.uiuc.edu


Created an attachment (id=6202)
 --> (http://llvm.org/bugs/attachment.cgi?id=6202)
Reduced test case

When a struct is initialized using a function, the analyzer does not detect
that it has been initialized and warns about garbage value.

------------- struct.cpp

typedef struct CGSize { float width; float height; } CGSize;

extern CGSize CGSizeMake(float w, float h);

float test() {
    CGSize s = CGSizeMake(0, 0);
    return s.width;
}

-------------
% clang++ --analyze struct.cpp
struct.cpp:8:2: warning: Undefined or garbage value returned to caller
        return s.width;
        ^      ~~~~~~~
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