Skip to content

CHECKER: Track '<', '>', etc. relationships between symbolic values #2678

@edwintorok

Description

@edwintorok
Bugzilla Link 2306
Resolution DUPLICATE
Resolved on Dec 23, 2018 05:51
Version unspecified
OS Linux
Blocks llvm/llvm-bugzilla-archive#4272 llvm/llvm-bugzilla-archive#5628
Attachments checker html report
CC @tkremenek,@haoNoQ

Extended Description

Using SVN r50942:

/home/edwin/llvm-svn/llvm/tools/clang/utils/ccc-analyzer -c path_sens.c
path_sens.c
ANALYZE: path_sens.c foo
path_sens.c:10:11: warning: [CHECKER] Dereference of null pointer.
return *bar;
^~~
1 diagnostic generated.

int foo(int left, int right)
{
int x=5;
int *bar = 0;
while(left<=right) {
left++;
bar = &x;
}
if(left<=right) {
return *bar;
}
return 0;
}

See the attached html report, it says that the while() condition is false, and then the if() condition is true.
That can't happen, after the while (left<=right) is always false, hence the if is never entered.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions