https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92831
--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Author: jakub Date: Fri Dec 20 17:37:45 2019 New Revision: 279669 URL: https://gcc.gnu.org/viewcvs?rev=279669&root=gcc&view=rev Log: Backported from mainline 2019-12-06 Jakub Jelinek <ja...@redhat.com> PR c++/92831 - CWG 1299, not extending temporary lifetime for ?: * cp-tree.h (extend_ref_init_temps): Add a new argument with NULL default arg. * call.c (set_up_extended_ref_temp): Add COND_GUARD argument, pass it down to extend_ref_init_temps. Before pushing cleanup, if COND_GUARD is non-NULL, create a bool temporary if needed, initialize to false and guard the cleanup with the temporary being true. (extend_ref_init_temps_1): Add COND_GUARD argument, pass it down to recursive calls and set_up_extended_ref_temp. Handle COND_EXPR. (extend_ref_init_temps): Add COND_GUARD argument, pass it down to recursive calls and to extend_ref_init_temps_1. * g++.dg/cpp0x/temp-extend2.C: New test. Added: branches/gcc-9-branch/gcc/testsuite/g++.dg/cpp0x/temp-extend2.C Modified: branches/gcc-9-branch/gcc/cp/ChangeLog branches/gcc-9-branch/gcc/cp/call.c branches/gcc-9-branch/gcc/cp/cp-tree.h branches/gcc-9-branch/gcc/testsuite/ChangeLog