[llvm-bugs] [Bug 38653] New: The argument to __has_builtin (and maybe __has_feature?) should be macro-expanded.

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Aug 20 17:55:13 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=38653

            Bug ID: 38653
           Summary: The argument to __has_builtin (and maybe
                    __has_feature?) should be macro-expanded.
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: bmoses at google.com
                CC: llvm-bugs at lists.llvm.org

I was working around bug 16404 (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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180821/e65f951c/attachment.html>


More information about the llvm-bugs mailing list