<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 - scan-build reports false-positive with boost signals"
href="https://bugs.llvm.org/show_bug.cgi?id=52544">52544</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>scan-build reports false-positive with boost signals
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>13.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</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>florian@apolloner.eu
</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=25457" name="attach_25457" title="HTML output of scan-build">attachment 25457</a> <a href="attachment.cgi?id=25457&action=edit" title="HTML output of scan-build">[details]</a></span>
HTML output of scan-build
Hi there,
I have scan-build reporting a false positive. I am not 100% sure though, since
this code is a bit over my head and my analysis might have been wrong.
What I did so far:
* I ran valgrind --track-origins=yes --leak-check=full and
* the address sanitizer (-O1 -g -fsanitize=address -fno-omit-frame-pointer)
over the code and they did not complain.
Looking through the report I think it might indeed be a bug in scan-build
(although it might not be easily fixable and might have to be reported to boost
signals2/smart_ptr instead).
I have attached the generated html output, the cpp in question is:
```
#include <boost/signals2.hpp>
#include <boost/bind/bind.hpp>
#include <iostream>
using namespace boost;
using namespace boost::signals2;
using namespace std;
signal<void ()> SigA;
struct ClassB
{
void PrintFoo() { cout << "Foo" << endl; }
};
int main()
{
ClassB b;
SigA.connect(bind(&ClassB::PrintFoo, &b));
}
```
and scan-build reports:
```
scan-build: Using '/usr/bin/clang-13' for static analysis
In file included from test.cpp:1:
In file included from /usr/include/boost/signals2.hpp:15:
In file included from /usr/include/boost/signals2/deconstruct.hpp:28:
In file included from /usr/include/boost/shared_ptr.hpp:17:
In file included from /usr/include/boost/smart_ptr/shared_ptr.hpp:17:
/usr/include/boost/smart_ptr/detail/shared_count.hpp:586:22: warning: Use of
memory after it is freed [cplusplus.NewDelete]
if(pi_ != 0) pi_->weak_release();
^~~~~~~~~~~~~~~~~~~
1 warning generated.
scan-build: Analysis run complete.
scan-build: 1 bug found.
scan-build: Run 'scan-view /tmp/scan-build-2021-11-18-124707-36387-1' to
examine bug reports.
```
Please let me know what you need and whether I should report this to boost
instead.</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>