The following valid code snippet (compiled with -std=c++1y) triggers an ICE since GCC 5.1.0: ===================== struct A { A* p = this; }; void foo() { A a; a = A({}); } ===================== bug.cc: In function 'void foo()': bug.cc:9:5: internal compiler error: in gimplify_expr, at gimplify.c:11950 a = A({}); ~~^~~~~~~ 0xaeacfc gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) ../../gcc/gcc/gimplify.c:11950 0xae80e0 gimplify_addr_expr ../../gcc/gcc/gimplify.c:5859 0xae80e0 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) ../../gcc/gcc/gimplify.c:11238 0xaf17c0 gimplify_init_ctor_preeval ../../gcc/gcc/gimplify.c:4241 0xaf1778 gimplify_init_ctor_preeval ../../gcc/gcc/gimplify.c:4227 0xaf225c gimplify_init_constructor ../../gcc/gcc/gimplify.c:4796 0xaf3096 gimplify_modify_expr_rhs ../../gcc/gcc/gimplify.c:5082 0xaf9dd0 gimplify_modify_expr ../../gcc/gcc/gimplify.c:5417 0xae897c gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) ../../gcc/gcc/gimplify.c:11191 0xaeb8d8 gimplify_stmt(tree_node**, gimple**) ../../gcc/gcc/gimplify.c:6478 0xae7a7a gimplify_cleanup_point_expr ../../gcc/gcc/gimplify.c:6230 0xae7a7a gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) ../../gcc/gcc/gimplify.c:11567 0xaeb8d8 gimplify_stmt(tree_node**, gimple**) ../../gcc/gcc/gimplify.c:6478 0xae71cb gimplify_statement_list ../../gcc/gcc/gimplify.c:1716 0xae71cb gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) ../../gcc/gcc/gimplify.c:11619 0xaeb8d8 gimplify_stmt(tree_node**, gimple**) ../../gcc/gcc/gimplify.c:6478 0xaec9a8 gimplify_bind_expr ../../gcc/gcc/gimplify.c:1290 0xae7b7a gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) ../../gcc/gcc/gimplify.c:11391 0xaeb8d8 gimplify_stmt(tree_node**, gimple**) ../../gcc/gcc/gimplify.c:6478 0xaed911 gimplify_body(tree_node*, bool) ../../gcc/gcc/gimplify.c:12388 Please submit a full bug report, [etc.]
Confirmed.
Started with r216750.
gimplify_expr can't stomach <PLACEHOLDER_EXPR struct A> created in get_nsdmi. Wait, there's a dup or at least a very similar PR.
That was PR77659 which has been fixed on the trunk.
Surprisingly my naïve attempt to fix this works: --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -8047,6 +8047,8 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain) { arg = cp_build_indirect_ref (arg, RO_NULL, complain); val = build2 (MODIFY_EXPR, TREE_TYPE (to), to, arg); + if (cxx_dialect >= cxx14) + replace_placeholders (arg, to); } else { and the C++ testsuite passes.
Author: mpolacek Date: Mon Mar 6 17:38:42 2017 New Revision: 245927 URL: https://gcc.gnu.org/viewcvs?rev=245927&root=gcc&view=rev Log: PR c++/79796 - ICE with NSDMI and this pointer * call.c (build_over_call): Handle NSDMI with a 'this' by calling replace_placeholders. * g++.dg/cpp0x/nsdmi13.C: New test. Added: trunk/gcc/testsuite/g++.dg/cpp0x/nsdmi13.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/call.c trunk/gcc/testsuite/ChangeLog
Fixed on the trunk so far.
Author: mpolacek Date: Tue Mar 7 17:42:30 2017 New Revision: 245957 URL: https://gcc.gnu.org/viewcvs?rev=245957&root=gcc&view=rev Log: PR c++/79796 - ICE with NSDMI and this pointer * call.c (build_over_call): Handle NSDMI with a 'this' by calling replace_placeholders. * g++.dg/cpp0x/nsdmi13.C: New test. Added: branches/gcc-6-branch/gcc/testsuite/g++.dg/cpp0x/nsdmi13.C Modified: branches/gcc-6-branch/gcc/cp/ChangeLog branches/gcc-6-branch/gcc/cp/call.c branches/gcc-6-branch/gcc/testsuite/ChangeLog
Fixed in GCC 6 too.