<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/117166>117166</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            __builtin_bit_cast does not allow bitcasting from nullptr_t
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang:frontend,
            constexpr
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          tbaederr
      </td>
    </tr>
</table>

<pre>
    `nullptr_t` is not a pointer type, see the `static_assert` in https://godbolt.org/z/vjq1Tse7W


In this example, the second bitcast works, but the first one does not:
```c++
typedef __UINTPTR_TYPE__ uintptr_t;
constexpr uintptr_t A = __builtin_bit_cast(uintptr_t, nullptr);


typedef decltype(nullptr) nullptr_t;
constexpr decltype(nullptr) N = __builtin_bit_cast(nullptr_t, (uintptr_t)12);
static_assert(N == nullptr);
```
The output suggests some bogus reason though:

```console
./array.cpp:26:21: error: constexpr variable 'A' must be initialized by a constant expression
   26 | constexpr uintptr_t A = __builtin_bit_cast(uintptr_t, nullptr);
      | ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./array.cpp:26:25: note: indeterminate value can only initialize an object of type 'unsigned char' or 'std::byte'; 'unsigned long' is invalid
   26 | constexpr uintptr_t A = __builtin_bit_cast(uintptr_t, nullptr);
      | ^
```

GCC accepts the first one, but not the second. I opened https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117727 for that.

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8VFGPozYQ_jXmZXQITALJAw-57FHty-lUbVX1CRkzAV8dm9rj7GUf-tsrw-bY3dtWfaiKkEnGnplvvg8-4b0aDGLNth_Z9i4RgUbrauoE9uhc0tn-WrMyM0HriVxLrMxAeTCWQMBklSF0QNcJGT-CRwQaEViZeRKkZCu8R7ckGRiJJs-KA-MN481g-85qSq0bGG-eGG8uX__IHzx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