[clang] [Clang] Extend lifetime of temporaries in mem-default-init for P2718R0 (PR #86960)
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 10 13:08:36 PDT 2024
================
@@ -1230,11 +1230,26 @@ CodeGenFunction::EmitCXXForRangeStmt(const CXXForRangeStmt &S,
JumpDest LoopExit = getJumpDestInCurrentScope("for.end");
LexicalScope ForScope(*this, S.getSourceRange());
+ const DeclStmt *RangeDS = cast<DeclStmt>(S.getRangeStmt());
+ const VarDecl *RangeVar = cast<VarDecl>(RangeDS->getSingleDecl());
+ if (getLangOpts().CPlusPlus23)
----------------
zygoloid wrote:
Thr quoted rule is [class.base.init]/11, and in that context is describing the behavior of the initialization of class members in a constructor.
Aggregate initialization is handled by the general rule in [class.temporary] but see also the [note in [dcl.init.general]](https://eel.is/c++draft/dcl.init#general-16.6.2.2.sentence-8) that explicitly mentions this case.
https://github.com/llvm/llvm-project/pull/86960
More information about the cfe-commits
mailing list