[llvm-bugs] [Bug 40299] New: Static Analyzer emits false-positive warnings for reference-count code
via llvm-bugs
llvm-bugs at lists.llvm.org
Sat Jan 12 20:14:02 PST 2019
https://bugs.llvm.org/show_bug.cgi?id=40299
Bug ID: 40299
Summary: Static Analyzer emits false-positive warnings for
reference-count code
Product: clang
Version: trunk
Hardware: Macintosh
OS: MacOS X
Status: NEW
Severity: normal
Priority: P
Component: Static Analyzer
Assignee: dcoughlin at apple.com
Reporter: jaf at meyersound.com
CC: dcoughlin at apple.com, llvm-bugs at lists.llvm.org
Created attachment 21317
--> https://bugs.llvm.org/attachment.cgi?id=21317&action=edit
An MCVE that demonstrates/reproduces the fault described in this case.
Running the Static Analyzer (built from a checkout of today's SVN trunk, llvm
SVN revision 351016) on the attached toy C++ program yields the following
false-positive warnings:
$ scan-build clang++ simple_refcount_demo.cpp -o simple_refcount_demo -isysroot
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
scan-build: Using '/Users/jaf/build_clang/_build/bin/clang-8' for static
analysis
simple_refcount_demo.cpp:43:54: warning: Use of memory after it is freed
const MyRefCountedObject * GetObject() const {return _obj;}
^~~~~~~~~~~
simple_refcount_demo.cpp:52:8: warning: Potential memory leak
}
^
2 warnings generated.
scan-build: 2 bugs found.
These warnings are false-positives because the simple reference-counting
(implemented in the MyRef and MyRefCountedObject classes in the toy program)
ensures that no memory is leaked and that the allocated MyRefCountedObject
remains valid until it can no longer be accessed.
--
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/20190113/3107e472/attachment.html>
More information about the llvm-bugs
mailing list