[clang] [clang] Fix a crash when dynamic_cast-ing to a `final` class (PR #148088)

Oliver Hunt via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 15 00:00:53 PDT 2025


================
@@ -2341,8 +2341,15 @@ llvm::Value *CodeGenFunction::EmitDynamicCast(Address ThisAddr,
   } else if (IsExact) {
     // If the destination type is effectively final, this pointer points to the
     // right type if and only if its vptr has the right value.
-    Value = CGM.getCXXABI().emitExactDynamicCast(
-        *this, ThisAddr, SrcRecordTy, DestTy, DestRecordTy, CastEnd, CastNull);
+    std::optional<llvm::Value *> ExactCast =
+        CGM.getCXXABI().emitExactDynamicCast(*this, ThisAddr, SrcRecordTy,
----------------
ojhunt wrote:

@efriedma-quic ah right, the issue is it is simultaneously working out if there is a path and working out the offset that should be taken. But I think that can be computed as a cumulative offset.

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


More information about the cfe-commits mailing list