[clang] [Clang] Fix a crash when diagnosing a non relocatable with no copy ctr (PR #143350)

Oliver Hunt via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 9 00:40:38 PDT 2025


================
@@ -2052,7 +2052,7 @@ static void DiagnoseNonTriviallyRelocatableReason(Sema &SemaRef,
   }
 
   if (!D->hasSimpleMoveConstructor() && !D->hasSimpleCopyConstructor()) {
-    const auto *Decl = cast<CXXConstructorDecl>(
+    const auto *Decl = cast_or_null<CXXConstructorDecl>(
----------------
ojhunt wrote:

I didn't realize that this path was being hit solely as a "is there some other constructor?" check, I was paranoid that there was a prior state error that meant a constructor was expected to exist.

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


More information about the cfe-commits mailing list