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

            Bug ID: 51759
           Summary: x86-64: __builtin_bit_cast(anything, long double)
                    wrongly errors with "indeterminate value"
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected], [email protected]

On a plain old x86-64 Linux or OSX system, where `long double` is 128-bit and
IEC559 standard as far as I know:

constexpr int f() {
    long double ld = 1.0;
    __uint128_t u = __builtin_bit_cast(__uint128_t, ld);
    return 4;
}
int a[f()];

GCC is happy with this program. Clang complains:

<source>:1:15: error: constexpr function never produces a constant expression
[-Winvalid-constexpr]
constexpr int f() {
              ^
<source>:3:21: note: indeterminate value can only initialize an object of type
'unsigned char' or 'std::byte'; 'unsigned __int128' is invalid
    __uint128_t u = __builtin_bit_cast(__uint128_t, ld);
                    ^

And it's not only when converting to __uint128_t; converting to a trivial
16-byte struct type gives the same diagnostic. It seems that Clang flatly
doesn't support __builtin_bit_cast from a `long double` source operand.

https://godbolt.org/z/EYraxf9aY

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to