<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
span.EmailStyle18
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=HU link=blue vlink=purple style='word-wrap:break-word'><div class=WordSection1><p class=MsoNormal><span lang=EN-US style='mso-fareast-language:EN-US'>I still failed to reproduce this on 424fe903d4d4b0f52bd4f86f62587efa6561d251 Fri Jul 23 12:51:37.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='mso-fareast-language:EN-US'>Please file a ticket on the official Bugzilla tracker about this if you have the necessary information/reproducer.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='mso-fareast-language:EN-US'>Try dumping the preprocessed file, that might be different on my system.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='mso-fareast-language:EN-US'>Balazs<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='mso-fareast-language:EN-US'><o:p> </o:p></span></p><div style='border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b><span lang=EN-US>From:</span></b><span lang=EN-US> Tamir Zahavi-Brunner <tamir.z3@gmail.com> <br><b>Sent:</b> 2021. július 28., szerda 10:30<br><b>To:</b> Benics Balázs <benicsbalazs@gmail.com><br><b>Cc:</b> cfe-dev@lists.llvm.org<br><b>Subject:</b> Re: [cfe-dev] [clang-tidy] Issues with C++17 structured bindings<o:p></o:p></span></p></div><p class=MsoNormal><o:p> </o:p></p><div><div><div><div><p class=MsoNormal>The full contents of the file are:<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>#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>}<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>And the line I run which gives me the above errors is:<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>clang-tidy test.cpp -- --std=c++17<o:p></o:p></p></div></div></div></div><p class=MsoNormal><o:p> </o:p></p><div><div><p class=MsoNormal>On Wed, Jul 28, 2021 at 11:06 AM Benics Balázs <<a href="mailto:benicsbalazs@gmail.com">benicsbalazs@gmail.com</a>> wrote:<o:p></o:p></p></div><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm'><div><div><p class=MsoNormal style='background:white'><span style='color:#212121'>Hi,<o:p></o:p></span></p></div><div><p class=MsoNormal style='background:white'><span style='color:#212121'>It seems like its a Clang Static Analyzer checker warns about something.<o:p></o:p></span></p></div><div><p class=MsoNormal style='background:white'><span style='color:#212121'><o:p> </o:p></span></p></div><div><p class=MsoNormal style='background:white'><span style='color:#212121'>Could you please send the complete reproducer?<o:p></o:p></span></p></div><div><p class=MsoNormal style='background:white'><span style='color:#212121'>I failed reproducing this.<o:p></o:p></span></p></div><div><p class=MsoNormal style='background:white'><span style='color:#212121'><o:p> </o:p></span></p></div><div><p class=MsoNormal style='background:white'><span style='color:#212121'>Regards,<o:p></o:p></span></p></div><div><p class=MsoNormal style='background:white'><span style='color:#212121'>Balazs<o:p></o:p></span></p></div><div id="gmail-m_-7091691624240492897ms-outlook-mobile-signature"><div><p class=MsoNormal><o:p> </o:p></p></div><p class=MsoNormal><o:p> </o:p></p></div><div class=MsoNormal align=center style='text-align:center'><hr size=2 width="98%" align=center></div><div id="gmail-m_-7091691624240492897divRplyFwdMsg"><p class=MsoNormal><b><span style='color:black'>From:</span></b><span style='color:black'> 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</span> <o:p></o:p></p><div><p class=MsoNormal> <o:p></o:p></p></div></div><div><div><div><p class=MsoNormal>Hello,<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>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:<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>auto [ptr, num] = std::make_tuple(malloc(1), 1);<br>free(ptr);<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>For which I get the following warning:<o:p></o:p></p></div><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal>/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> ^<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>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.<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>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?<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Thanks,<o:p></o:p></p></div><div><p class=MsoNormal>Tamir<o:p></o:p></p></div></div></div></div></blockquote></div></div></body></html>