[clang] [Sema] Fix lifetime extension for temporaries in range-based for loops in C++23 (PR #145164)

Marco Vitale via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 3 10:28:26 PDT 2025


================
@@ -1304,6 +1304,13 @@ checkExprLifetimeImpl(Sema &SemaRef, const InitializedEntity *InitEntity,
   if (LK == LK_FullExpression)
     return;
 
+  if (LK == LK_Extended && SemaRef.getLangOpts().CPlusPlus23) {
----------------
mrcvtl wrote:

Yes, we can. We just need to check also for `InitEntity != nullptr` and it works I guess.

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


More information about the cfe-commits mailing list