<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Static Analyzer emits false-positive warnings for reference-count code"
href="https://bugs.llvm.org/show_bug.cgi?id=40299">40299</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Static Analyzer emits false-positive warnings for reference-count code
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>Macintosh
</td>
</tr>
<tr>
<th>OS</th>
<td>MacOS X
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Static Analyzer
</td>
</tr>
<tr>
<th>Assignee</th>
<td>dcoughlin@apple.com
</td>
</tr>
<tr>
<th>Reporter</th>
<td>jaf@meyersound.com
</td>
</tr>
<tr>
<th>CC</th>
<td>dcoughlin@apple.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=21317" name="attach_21317" title="An MCVE that demonstrates/reproduces the fault described in this case.">attachment 21317</a> <a href="attachment.cgi?id=21317&action=edit" title="An MCVE that demonstrates/reproduces the fault described in this case.">[details]</a></span>
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.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>