================
@@ -10950,6 +10950,9 @@ bool
ArrayExprEvaluator::VisitCXXParenListOrInitListExpr(
}
bool ArrayExprEvaluator::VisitArrayInitLoopExpr(const ArrayInitLoopExpr *E) {
+
+ FullExpressionRAII Scope(Info);
+
----------------
zygoloid wrote:
This should be done after we evaluate the common expression, not before, and
should be *inside* the `for` loop below so that we destroy temporaries after
each iteration of the initialization loop. That is, the individual element
initialization should be treated as a full-expression, but the evaluation of
the source (typically array) expression should not.
This fixes a conformance issue with default arguments (though it's a little
hard to observe given that it's hard to give constant-evaluated default
arguments side effects). The relevant standard wording is
https://eel.is/c++draft/class.temporary#5; adding a comment saying this is
implementing C++ [class.temporary]/5 would be helpful.
IR generation gets this right already; the corresponding implementation there
is this
`RunCleanupsScope`:https://github.com/llvm/llvm-project/blob/d28a782542aff50abf2b072780748ce57d982705/clang/lib/CodeGen/CGExprAgg.cpp#L1882
https://github.com/llvm/llvm-project/pull/67722
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits