[llvm-bugs] [Bug 34365] New: Static analyzer is very conservative with atomic ops
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Aug 29 17:24:50 PDT 2017
https://bugs.llvm.org/show_bug.cgi?id=34365
Bug ID: 34365
Summary: Static analyzer is very conservative with atomic ops
Product: clang
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: Static Analyzer
Assignee: kremenek at apple.com
Reporter: george.burgess.iv at gmail.com
CC: llvm-bugs at lists.llvm.org
$ cat tc.cpp
void bar() {
int i = 2;
char *c = new char;
if (__sync_fetch_and_sub(&i, 1) == 1) delete c;
if (__sync_fetch_and_sub(&i, 1) == 1) delete c;
}
$ clang++ --analyze tc.cpp -std=c++11
tc.cpp:5:41: warning: Attempt to free released memory
if (__sync_fetch_and_sub(&i, 1) == 1) delete c;
^~~~~~~~
tc.cpp:6:1: warning: Potential leak of memory pointed to by 'c'
}
^
I'm unsure if it's possible to do much better than this in general, since
atomic ops are inherently annoying to reason about. That said, this issue makes
the analyzer pretty noisy when it's analyzing home-grown shared_ptr
implementations.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170830/1dd5b819/attachment.html>
More information about the llvm-bugs
mailing list