Skip to content

Static analyzer fails to track path invariants involving bitmasks. #10571

@llvmbot

Description

@llvmbot
Bugzilla Link 10199
Resolution DUPLICATE
Resolved on Apr 03, 2014 13:39
Version trunk
OS MacOS X
Reporter LLVM Bugzilla Contributor
CC @belkadan

Extended Description

%%%
void f(unsigned);
void g(unsigned, unsigned);

void
f(unsigned flags)
{
unsigned inbytes, outbytes;

if ((flags & 1) != 0)
	inbytes = outbytes = 0;

if ((flags & 1) != 0)
	g(inbytes, outbytes);

}
%%%

Yields:

%%%
x.cc:13:3: warning: Function call argument is an uninitialized value
g(inbytes, outbytes);
%%%

Eliminating the bitmask (i.e. "if (flags != 0)") the analyzer detects that inbytes and outbytes are always initialized.

Version:

%%%
clang version 3.0 (trunk 133679)
Target: x86_64-apple-darwin10.7.0
Thread model: posix
%%%

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions