llvm-project
llvm-project copied to clipboard
False positive error in scan-build: bit logic
| 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.
mentioned in issue llvm/llvm-project#3470
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 ***
assigned to @tkremenek