This code crashes GCC 6.1 when optimisations are enabled: ----------------------------------------------------------- struct Destr { ~Destr(); }; struct XX { Destr func() { throw "throw"; return {}; } }; inline void call(Destr (XX::*f)(), XX *o) { (o->*f)(); } void f(XX *o) { call(&XX::func, o); } ----------------------------------------------------------- Live demo: http://melpon.org/wandbox/permlink/GyM44dSdEnvqqmZN
Confirmed. > ./cc1plus -quiet t.ii -O2 t.ii: In function 'void f(XX*)': t.ii:14:12: internal compiler error: in assign_temp, at function.c:961 (o->*f)(); ^ 0xd285c3 assign_temp(tree_node*, int, int) /space/rguenther/src/svn/trunk/gcc/function.c:961 0xb50440 expand_call(tree_node*, rtx_def*, int) /space/rguenther/src/svn/trunk/gcc/calls.c:2569 0xcccb6c expand_expr_real_1(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**, bool) /space/rguenther/src/svn/trunk/gcc/expr.c:10610 0xcc1633 expand_expr_real(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**, bool) /space/rguenther/src/svn/trunk/gcc/expr.c:7962 0xb60525 expand_expr /space/rguenther/src/svn/trunk/gcc/expr.h:256 0xb68681 expand_call_stmt
Started with r232167.
Created attachment 38512 [details] gcc7-pr71100.patch Untested fix.
Author: jakub Date: Wed May 18 21:23:07 2016 New Revision: 236430 URL: https://gcc.gnu.org/viewcvs?rev=236430&root=gcc&view=rev Log: PR c++/71100 * cgraph.c (cgraph_edge::redirect_call_stmt_to_callee): Don't drop lhs if it has TREE_ADDRESSABLE type. * g++.dg/opt/pr71100.C: New test. Added: trunk/gcc/testsuite/g++.dg/opt/pr71100.C Modified: trunk/gcc/ChangeLog trunk/gcc/cgraph.c trunk/gcc/testsuite/ChangeLog
Author: jakub Date: Wed May 18 21:24:16 2016 New Revision: 236431 URL: https://gcc.gnu.org/viewcvs?rev=236431&root=gcc&view=rev Log: PR c++/71100 * cgraph.c (cgraph_edge::redirect_call_stmt_to_callee): Don't drop lhs if it has TREE_ADDRESSABLE type. * g++.dg/opt/pr71100.C: New test. Added: branches/gcc-6-branch/gcc/testsuite/g++.dg/opt/pr71100.C Modified: branches/gcc-6-branch/gcc/ChangeLog branches/gcc-6-branch/gcc/cgraph.c branches/gcc-6-branch/gcc/testsuite/ChangeLog
Fixed.
*** Bug 71553 has been marked as a duplicate of this bug. ***