<div dir="ltr"><div dir="ltr"><div dir="ltr"><div>The full contents of the file are:</div><div><br></div><div>#include <malloc.h><br>#include <tuple><br><br>int main()<br>{<br>    auto [ptr, num] = std::make_tuple(malloc(1), 1);<br>    free(ptr);<br><br>    return 0;<br>}</div><div><br></div><div>And the line I run which gives me the above errors is:</div><div><br></div><div>clang-tidy test.cpp -- --std=c++17</div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jul 28, 2021 at 11:06 AM Benics Balázs <<a href="mailto:benicsbalazs@gmail.com">benicsbalazs@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">



<div>
<div style="color:rgb(33,33,33);background-color:rgb(255,255,255)" dir="auto">
Hi,</div>
<div style="color:rgb(33,33,33);background-color:rgb(255,255,255)" dir="auto">
It seems like its a Clang Static Analyzer checker warns about something.</div>
<div style="color:rgb(33,33,33);background-color:rgb(255,255,255)" dir="auto">
<br>
</div>
<div style="color:rgb(33,33,33);background-color:rgb(255,255,255)" dir="auto">
Could you please send the complete reproducer?</div>
<div style="color:rgb(33,33,33);background-color:rgb(255,255,255)" dir="auto">
I failed reproducing this.</div>
<div style="color:rgb(33,33,33);background-color:rgb(255,255,255)" dir="auto">
<br>
</div>
<div style="color:rgb(33,33,33);background-color:rgb(255,255,255)" dir="auto">
Regards,</div>
<div style="color:rgb(33,33,33);background-color:rgb(255,255,255)" dir="auto">
Balazs</div>
<div id="gmail-m_-7091691624240492897ms-outlook-mobile-signature">
<div><br>
</div>
<div dir="auto" style="text-align:left"><br>
</div>
</div>
<hr style="display:inline-block;width:98%">
<div id="gmail-m_-7091691624240492897divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" face="Calibri, sans-serif" color="#000000"><b>From:</b> cfe-dev <<a href="mailto:cfe-dev-bounces@lists.llvm.org" target="_blank">cfe-dev-bounces@lists.llvm.org</a>> on behalf of Tamir Zahavi-Brunner via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>><br>
<b>Sent:</b> Tuesday, July 6, 2021 1:25:12 PM<br>
<b>To:</b> <a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a> <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>><br>
<b>Subject:</b> [cfe-dev] [clang-tidy] Issues with C++17 structured bindings</font>
<div> </div>
</div>
<div>
<div dir="ltr">
<div>Hello,</div>
<div><br>
</div>
<div>Using clang-tidy-12, I'm getting false warnings when using structured bindings. There can actually be a variety of issues, but here is a very small example I've narrowed it down to:</div>
<div><br>
</div>
<div>auto [ptr, num] = std::make_tuple(malloc(1), 1);<br>
free(ptr);</div>
<div><br>
</div>
<div>For which I get the following warning:<br>
</div>
<br>
<div>/tmp/test.cpp:7:5: warning: Potential leak of memory pointed to by '._M_head_impl' [clang-analyzer-unix.Malloc]<br>
    free(ptr);<br>
    ^<br>
/tmp/test.cpp:6:39: note: Memory is allocated<br>
    auto [ptr, num] = std::make_tuple(malloc(1), 1);<br>
                                      ^<br>
/tmp/test.cpp:7:5: note: Potential leak of memory pointed to by '._M_head_impl'<br>
    free(ptr);<br>
    ^<br>
</div>
<div><br>
</div>
<div>Searching online, I saw that I'm not the first person to encounter such issues (<a href="https://stackoverflow.com/questions/62706928/clang-tidy-vs-structured-bindings" target="_blank">https://stackoverflow.com/questions/62706928/clang-tidy-vs-structured-bindings</a>)
 but I couldn't find any solution.</div>
<div><br>
</div>
<div>Is this a bug in clang-tidy or am I missing something? Is there anything I can do to solve this other than stopping using structured bindings?</div>
<div><br>
</div>
<div>Thanks,</div>
<div>Tamir<br>
</div>
</div>
</div>
</div>

</blockquote></div>