diff --git a/gcc/testsuite/g++.dg/pr45310.C b/gcc/testsuite/g++.dg/pr45310.C new file mode 100644 index 000000000000..335c782570f4 --- /dev/null +++ b/gcc/testsuite/g++.dg/pr45310.C @@ -0,0 +1,31 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fnon-call-exceptions" } */ + +static inline const int & +max (const int &a, const int &b) +{ + return a ? a : b; +} + +static inline int +baz () +{ + return max (0, 0); +} + +struct S +{ + ~S () + { + baz (); + } +}; + +void bar (); +void +foo () +{ + S s; + bar (); +} + diff --git a/gcc/tree-ssa-phiprop.c b/gcc/tree-ssa-phiprop.c index 614546bed120..a38e6962f951 100644 --- a/gcc/tree-ssa-phiprop.c +++ b/gcc/tree-ssa-phiprop.c @@ -352,7 +352,7 @@ propagate_with_phi (basic_block bb, gimple phi, struct phiprop_d *phivn, want to delete it here we also have to delete all intermediate copies. */ gsi = gsi_for_stmt (use_stmt); - gsi_remove (&gsi, false); + gsi_remove (&gsi, true); phi_inserted = true; }