<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/129842>129842</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[asan] failure to detect memory leaks
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
PikachuHyA
</td>
</tr>
</table>
<pre>
reproducer
see https://godbolt.org/z/6YGdnn634
```c++
// main.cc
struct Foo {
struct Foo *other;
};
int main() {
auto f1 = new Foo();
auto f2 = new Foo();
f1->other = f2;
f2->other = f1;
return 0;
}
```
However, the following memory leaks detected.
see https://godbolt.org/z/n6jWbYTqY
```c++
struct Foo {
struct Foo *other;
};
int main() {
auto f1 = new Foo();
auto f2 = new Foo();
f1->other = f2;
// highlight here
// f2->other = f1;
return 0;
}
```
Note: GCC can detect the memory leaks.
if use `-fsanitize=leak`, the memory leaks detected.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzMVM1O5DwQfJrOxZqR004y5JBDYL7A6dMeVlpxdJxOYvDErH9A8PQrZwYYkFjt3laylJ_qqrSr2pHe62khaqC8hHKfyRhm65pv-l6qOd48t1lvh-fG0YOzQ1TkgLeeiM0hPHgQLWAH2E126K0JW-smwO4FsKtur4dlqUQBvE2r4selAC_T4icmO0i9bJVKssFFFVhnLYNdqmDs_BW2NszkQKzk3f54o5ewSgBeANZvRBmDZWPOQOzZQk9J4VhxZL0W4NcFY74B8d_6ybVoxDcEPyH5K-IoRLcw_t7jx80fH2_sEz2SA7xiYSY2WmPsk14mdqCDdc_MkLz3bKBAKtCwPZL-xPOluvvR337_eful5_-UxV87fBqNWU-z0dMc2EyOzpG_jOCj_8Db_20gEC27vrpiSi4ns9c4zkNI3uuRRU8MKr4ZvVx00C8EYp_wpHgK8XfRAW-zoRFDLWqZUZPvijwvL4QosrkpJRdSYD1Izndjr6jqJWGNElWVFzvKdIMcSy54yXe8FMVWCip7HEVNVS6KXEHB6SC12RrzeEjDkGnvIzU51hcFZkb2ZPx6uhFTCisKiOmwuyaRNn2cPBTcaB_8u0zQway_BenlAuWejVKb6IgF--rX-a6z6EzzaUJ1mGO_VfYA2CXd02Xz4OwdqQDYrd14wO7U7mODvwIAAP__LwlUXw">