https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118856
--- Comment #5 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The trunk branch has been updated by Jason Merrill <ja...@gcc.gnu.org>: https://gcc.gnu.org/g:6f7935b3fd60968cff1b3252edf40022f25705aa commit r15-7508-g6f7935b3fd60968cff1b3252edf40022f25705aa Author: Jason Merrill <ja...@redhat.com> Date: Thu Feb 13 11:54:48 2025 +0100 c++: -frange-for-ext-temps and reused temps [PR118856] Some things in the front-end use a TARGET_EXPR to create a temporary, then refer to its TARGET_EXPR_SLOT separately later; in this testcase, maybe_init_list_as_range does. So we need to handle that pattern in extend_all_temps. PR c++/118856 gcc/cp/ChangeLog: * call.cc (struct extend_temps_data): Add var_map. (extend_all_temps): Adjust. (set_up_extended_ref_temp): Make walk_data void*. (extend_temps_r): Remap variables. Handle pset here. Extend all TARGET_EXPRs. gcc/testsuite/ChangeLog: * g++.dg/cpp23/range-for9.C: New test.