[llvm-bugs] [Bug 51759] New: x86-64: __builtin_bit_cast(anything, long double) wrongly errors with "indeterminate value"

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Sep 5 13:55:20 PDT 2021


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: unassignedclangbugs at nondot.org
          Reporter: arthur.j.odwyer at gmail.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at metafoo.co.uk

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210905/b69ee83b/attachment.html>


More information about the llvm-bugs mailing list