[llvm-bugs] [Bug 47267] New: Unable to perform a constexpr float to uint bitcast

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Aug 21 03:35:00 PDT 2020


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

            Bug ID: 47267
           Summary: Unable to perform a constexpr float to uint bitcast
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: llvm-dev at redking.me.uk
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

The float<->uint style casts are unable to be performed as constexpr:

static __inline__ unsigned int __attribute__((__always_inline__))
_castf32_u32(float __A) {
  unsigned int D;
  __builtin_memcpy(&D, &__A, sizeof(__A));
  return D;
}

It fails with:

cannot constant evaluate 'memcpy' from object of type 'float' to object of type
'unsigned int'

  __builtin_memcpy(&D, &__A, sizeof(__A));

Are there any workarounds to this? Or could we relax this restriction under any
circumstances?

This is part of the work to make more of the x86 intrinsics constexpr.

-- 
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/20200821/6988cb0a/attachment-0001.html>


More information about the llvm-bugs mailing list