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

False positive error in scan-build: bit logic

Open socketpair opened this issue 10 years ago • 3 comments

Bugzilla Link 28187
Resolution DUPLICATE
Resolved on Jun 20, 2016 18:04
Version 3.8
OS Linux
CC @devincoughlin

Extended Description

#define F1 1 #define F2 2

int main (int argc, char **argv) { const char *space; int flags = argc;

if (flags & (F1 | F2)) space = "qwe";

if (flags & F1) return *space;

return 0; }

$ scan-build-3.8 gcc qwe.c scan-build: Using '/usr/lib/llvm-3.8/bin/clang' for static analysis qwe.c:17:12: warning: Dereference of undefined pointer value return *space; ^~~~~~ 1 warning generated. scan-build: 1 bug found.

Using constants 0, 1, 2 and 3 instead of argc will not trigger that bug.

socketpair avatar Jun 18 '16 13:06 socketpair

mentioned in issue llvm/llvm-project#3470

devincoughlin avatar Nov 26 '21 22:11 devincoughlin

The fundamental issue is that the analyzer doesn't track bit-wise constraints. This is tracked by https://llvm.org/bugs/show_bug.cgi?id=3098

*** This bug has been marked as a duplicate of bug llvm/llvm-project#3470 ***

devincoughlin avatar Jun 21 '16 01:06 devincoughlin

assigned to @tkremenek

socketpair avatar Jun 18 '16 13:06 socketpair