Right, but the root cause of the problem is that __builtin_va_start uses a reference type in C mode. Your patch is fixing one of the places where that doesn't work. So we have a choice: either we accept the cost of making references work well enough in C to handle this weird case, or we pick a different implementation strategy for __builtin_va_start. We don't have many options, because the type of va_list is determined by the ABI and the behavior of __builtin_va_start is defined by GCC, but we may be able to (for instance) inject a "#define __builtin_va_start(list, ...) __builtin_va_start_ptr(&(list), __VA_ARGS__)" rather than using a reference type.<br>
<br><div class="gmail_quote">On Thu, Aug 8, 2013 at 12:43 AM, Artyom Skrobov <span dir="ltr"><<a href="mailto:Artyom.Skrobov@arm.com" target="_blank">Artyom.Skrobov@arm.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">






<div lang="EN-GB" link="blue" vlink="purple">
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Richard, my patch doesn’t add support for reference types in C – it only adds the proper type-checking so that clang emits a meaningful error diagnostic in
 this case, instead of crashing with a segfault.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> <a href="mailto:metafoo@gmail.com" target="_blank">metafoo@gmail.com</a> [mailto:<a href="mailto:metafoo@gmail.com" target="_blank">metafoo@gmail.com</a>]
<b>On Behalf Of </b>Richard Smith<br>
<b>Sent:</b> 08 August 2013 00:57<br>
<b>To:</b> Artyom Skrobov<br>
<b>Cc:</b> Anton Korobeynikov; <a href="mailto:cfe-commits@cs.uiuc.edu" target="_blank">cfe-commits@cs.uiuc.edu</a></span></p><div class="im"><br>
<b>Subject:</b> Re: [PATCH] in C mode, __builtin_va_start tries to accept a reference, sees a record, decides it's a C++ class, then crashes because it isn't<u></u><u></u></div><p></p>
</div><div class="im">
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">This is truly hideous. Do we *really* want to support reference types in C, just so that we can handle __builtin_va_start?<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">On Tue, Aug 6, 2013 at 8:26 AM, Artyom Skrobov <<a href="mailto:Artyom.Skrobov@arm.com" target="_blank">Artyom.Skrobov@arm.com</a>> wrote:<u></u><u></u></p>
<p class="MsoNormal">Anton, thank you for your suggestion.<br>
<br>
Re-submitting the patch as an attachment.<u></u><u></u></p>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><br>
<br>
-----Original Message-----<br>
From: Anton Korobeynikov [mailto:<a href="mailto:anton@korobeynikov.info" target="_blank">anton@korobeynikov.info</a>]<br>
Sent: 05 August 2013 23:24<br>
To: Artyom Skrobov<br>
Cc: <a href="mailto:cfe-commits@cs.uiuc.edu" target="_blank">cfe-commits@cs.uiuc.edu</a><br>
Subject: Re: [PATCH] in C mode, __builtin_va_start tries to accept a reference, sees a record, decides it's a C++ class, then crashes because it isn't<br>
<br>
Please consider reading <a href="http://llvm.org/docs/DeveloperPolicy.html#making-a-patch" target="_blank">
http://llvm.org/docs/DeveloperPolicy.html#making-a-patch</a><br>
<br>
<br>
<u></u><u></u></p>
</div>
<div>
<div>
<p class="MsoNormal">-- IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person,
 use it for any purpose, or store or copy the information in any medium.  Thank you.<u></u><u></u></p>
</div>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu" target="_blank">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><u></u><u></u></p>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div></div><div class="im">
<br>
<font face="Arial" color="Black">-- IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents
 to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.<br>
</font>
</div></div>
</blockquote></div><br>