[llvm-bugs] [Bug 42949] New: __builtin_constant_p lowering is inconsistent, producing false-negatives

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Aug 9 13:14:25 PDT 2019


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

            Bug ID: 42949
           Summary: __builtin_constant_p lowering is inconsistent,
                    producing false-negatives
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C
          Assignee: unassignedclangbugs at nondot.org
          Reporter: george.burgess.iv at gmail.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

It appears that __builtin_constant_p will eagerly get lowered to `false` in the
frontend if clang has reason to believe that __bcp's argument may have
side-effects. This has unintuitive consequences: https://godbolt.org/z/P-8vLS

Looks like this is a result of some special casing added in r359844.

It's understandable that __builtin_constant_p is totally a best-effort thing,
and there may be cases where it produces odd results, but this particular case
seems like it may be pretty confusing to anyone who isn't willing to read
clang's source code. :)

-- 
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/20190809/d7b69a70/attachment.html>


More information about the llvm-bugs mailing list