[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:20:44 PDT 2026


================
@@ -2658,6 +2658,8 @@ Value *ScalarExprEmitter::VisitCastExpr(CastExpr *CE) {
     Address Addr =
         SourceLVal.getAddress().withElementType(CGF.ConvertTypeForMem(DestTy));
     LValue DestLV = CGF.MakeAddrLValue(Addr, DestTy);
+    if (SourceLVal.isVolatileQualified())
+      DestLV.getQuals().addVolatile();
----------------
hubert-reinterpretcast wrote:

> The standard specification for std::bit_cast doesn't actually say what happens if the operand is volatile.

That seems to be a real problem because there really isn't supposed to be an lvalue-to-rvalue conversion of the bound input glvalue, but trying to apply `volatile` semantics on the object representation would result in multiple volatile accesses. I'll report the issue tomorrow or later this week.

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


More information about the cfe-commits mailing list