llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

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

Open edwintorok opened this issue 18 years ago • 12 comments

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.

edwintorok avatar May 10 '08 11:05 edwintorok

mentioned in issue llvm/llvm-bugzilla-archive#7770

tkremenek avatar Nov 27 '21 05:11 tkremenek

mentioned in issue llvm/llvm-bugzilla-archive#7494

tkremenek avatar Nov 27 '21 05:11 tkremenek

mentioned in issue llvm/llvm-bugzilla-archive#5628

llvmbot avatar Nov 27 '21 05:11 llvmbot

mentioned in issue llvm/llvm-bugzilla-archive#4272

llvmbot avatar Nov 27 '21 02:11 llvmbot

mentioned in issue llvm/llvm-bugzilla-archive#40145

haoNoQ avatar Nov 27 '21 01:11 haoNoQ

Duping to the constraint solver umbrella.

*** This bug has been marked as a duplicate of bug llvm/llvm-bugzilla-archive#40145 ***

haoNoQ avatar Dec 23 '18 13:12 haoNoQ

*** Bug llvm/llvm-bugzilla-archive#7770 has been marked as a duplicate of this bug. ***

tkremenek avatar Aug 02 '10 21:08 tkremenek

*** Bug llvm/llvm-bugzilla-archive#7494 has been marked as a duplicate of this bug. ***

tkremenek avatar Jun 26 '10 07:06 tkremenek

*** Bug llvm/llvm-project#2677 has been marked as a duplicate of this bug. ***

tkremenek avatar Feb 21 '09 01:02 tkremenek

The analyzer treats the function parameters "left" and "right" as symbolic values. Currently the analyzer doesn't support tracking relational constraints (e.g., left <= right) between symbolic values. If you change the code to have "==" instead of "<=" then things will go as you expect. This is a limitation in the analysis that I wanted to address some day, and it's great that there is as a Bugzilla report for it now.

I've changed the report to an enhancement, and changed the title to reflect the problem. I've also accepted the bug.

tkremenek avatar May 11 '08 01:05 tkremenek

The checker doesn't evaluate all iterations of the loop. This may just be "not to be fixed".

lattner avatar May 10 '08 22:05 lattner

assigned to @tkremenek

edwintorok avatar May 10 '08 11:05 edwintorok