<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - x86-64: __builtin_bit_cast(anything, long double) wrongly errors with "indeterminate value""
   href="https://bugs.llvm.org/show_bug.cgi?id=51759">51759</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>x86-64: __builtin_bit_cast(anything, long double) wrongly errors with "indeterminate value"
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>-New Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>arthur.j.odwyer@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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.

<a href="https://godbolt.org/z/EYraxf9aY">https://godbolt.org/z/EYraxf9aY</a></pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>