Issue 185070
Summary [Clang] Confusing diagnostics on constexpr bit cast with casted pointer
Labels clang
Assignees
Reporter oToToT
    From https://github.com/llvm/llvm-project/pull/184865, we see that 
```cpp
#define fold(x) (__builtin_constant_p(x) ? (x) : (x))

constexpr long fn(void) {
  return __builtin_bit_cast(long, fold((long)&fn));
}
static_assert(fn() == 1);
```
is showing this diagnostics
```
<source>:6:15: error: static assertion _expression_ is not an integral constant _expression_
    6 | static_assert(fn() == 1);
      | ^~~~~~~~~
<source>:4:10: note: constexpr bit cast involving type 'long' is not yet supported
    4 |   return __builtin_bit_cast(long, fold((long)&fn));
      |          ^
<source>:6:15: note: in call to 'fn()'
    6 | static_assert(fn() == 1);
      |               ^~~~
1 error generated.
```

The message "constexpr bit cast involving type 'long' is not yet supported" is a bit confusing because `long` is actually supported and the real issue is that it's from a non-const value.

Compiler Explorer: https://godbolt.org/z/b85rxb5xe
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to