<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 - The argument to __has_builtin (and maybe __has_feature?) should be macro-expanded."
href="https://bugs.llvm.org/show_bug.cgi?id=38653">38653</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>The argument to __has_builtin (and maybe __has_feature?) should be macro-expanded.
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</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>Frontend
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>bmoses@google.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>I was working around <a class="bz_bug_link
bz_status_REOPENED "
title="REOPENED - __int128_t multiply with -fsanitize=undefined fails to link (undefined reference to __muloti4)"
href="show_bug.cgi?id=16404">bug 16404</a> (short version: __builtin_mul_overflow doesn't
work unless linking with compiler_rt), and since the relevant code guards the
usages with __has_builtin, Richard Smith suggested that I could hack around it
with this "extremely dubious hack":
-D__builtin_mul_overflow=__builtin_no_such_builtin
Unfortunately, this doesn't work, since __has_builtin doesn't macro-expand its
argument.
As Richard pointed out in private chat, "I'm not sure that hack failing is a
solid justification for changing it." On the other hand, this behavior is
surprising and inconsistent with what we'd get if __has_builtin were a true
function or macro, and I'd argue that that's a good reason to change it to be
less surprising.
And it's not just me that had this expectation -- the documentation for
__has_feature notes, "The feature name or extension name can also be specified
with a preceding and following __ (double underscore) to avoid interference
from a macro with the same name," so clearly the author of that documentation
assumed the argument would be macro-expanded.</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>