[clang] [clang] Bind the __builtin_bit_cast operand as std::bit_cast binds its parameter (PR #231830)
Hubert Tong via cfe-commits
cfe-commits at lists.llvm.org
Sun Oct 18 20:38:16 PDT 2026
================
@@ -3404,6 +3404,15 @@ void CastOperation::CheckBuiltinBitCast() {
return;
}
+ if (SrcExpr.get()->isGLValue() &&
----------------
hubert-reinterpretcast wrote:
> Volatile bit-fields are rejected, as with `std::bit_cast`.
Volatile rvalues should also be rejected: https://godbolt.org/z/9jb3b86fo
```cpp
struct A {};
using VA = volatile A;
void f(const auto &);
int main() {
A a;
f(static_cast<VA &&>(a)); // error
(void) __builtin_bit_cast(A, VA{});
}
```
https://github.com/llvm/llvm-project/pull/231830
More information about the cfe-commits
mailing list