[clang] [Clang][ExprConst] Handle APValue::LValue in BitCast (PR #184865)

Timm Baeder via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 5 23:17:10 PST 2026


tbaederr wrote:

The change itself looks fine to me, but it can lead to some weird diagnostics:
```c++
#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);
```
```console
array.cpp:714:15: error: static assertion expression is not an integral constant expression
  714 | static_assert(fn() == 1);
      |               ^~~~~~~~~
array.cpp:711:10: note: constexpr bit cast involving type 'long' is not yet supported
  711 |   return __builtin_bit_cast(long, fold((long)&fn));
      |          ^
array.cpp:714:15: note: in call to 'fn()'
  714 | static_assert(fn() == 1);
      |               ^~~~
```

but that's more a pre-existing problem and not introduced by this patch.

https://github.com/llvm/llvm-project/pull/184865


More information about the cfe-commits mailing list