Skip to content

False positive for uninitialized struct field. #9946

@llvmbot

Description

@llvmbot
Bugzilla Link 9574
Resolution WORKSFORME
Resolved on May 07, 2012 23:32
Version trunk
OS All
Attachments Reduced test case
Reporter LLVM Bugzilla Contributor
CC @tkremenek

Extended Description

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions