[LLVMbugs] [Bug 9574] New: False positive for uninitialized struct field.

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Mar 28 02:29:16 PDT 2011


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

           Summary: False positive for uninitialized struct field.
           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=6367)
 --> (http://llvm.org/bugs/attachment.cgi?id=6367)
Reduced test case

I attach a case where clang wrongly reports uninitialized field in nested
struct.

------ field.c ------
typedef struct { double x, y; } NSPoint;
typedef struct { NSPoint origin; } NSRect;

static const NSPoint NSZeroPoint = { 0, 0 };

double test(void) {
 NSRect frame = { NSZeroPoint };
 return frame.origin.x;
}
---------------------

$ clang --analyze field.c
field.c:8:2: warning: Undefined or garbage value returned to caller
 return frame.origin.x;
 ^      ~~~~~~~~~~~~~~
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