From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 128640 invoked by alias); 3 Mar 2017 16:34:18 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 128621 invoked by uid 89); 3 Mar 2017 16:34:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1554 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 03 Mar 2017 16:34:15 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 049EB11CA53 for ; Fri, 3 Mar 2017 16:34:16 +0000 (UTC) Received: from redhat.com (ovpn-204-150.brq.redhat.com [10.40.204.150]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v23GYCpN020803 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 3 Mar 2017 11:34:15 -0500 Date: Fri, 03 Mar 2017 16:34:00 -0000 From: Marek Polacek To: GCC Patches , Jason Merrill Subject: C++ PATCH to fix ICE with NSDMI and this pointer (PR c++/79796) Message-ID: <20170303163411.GQ3172@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.7.1 (2016-10-04) X-SW-Source: 2017-03/txt/msg00184.txt.bz2 We weren't replacing PLACEHOLDER_EXPR in the following testcase, leading to a crash in the gimplifier. The fix seems to be to use replace_placeholders, the question is where. These three functions have it: cp_gimplify_init_expr store_init_value build_new_1 But we call neither so I tried adding the call to build_over_call, right after we create the MODIFY_EXPR with the NSDMI, and that seemed to work out. Bootstrapped/regtested on x86_64-linux, ok for trunk? 2017-03-03 Marek Polacek 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. diff --git gcc/cp/call.c gcc/cp/call.c index dc629b96..b821224 100644 --- gcc/cp/call.c +++ gcc/cp/call.c @@ -8047,6 +8047,9 @@ 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) + /* Handle NSDMI that refer to the object being initialized. */ + replace_placeholders (arg, to); } else { diff --git gcc/testsuite/g++.dg/cpp0x/nsdmi13.C gcc/testsuite/g++.dg/cpp0x/nsdmi13.C index e69de29..2751da3 100644 --- gcc/testsuite/g++.dg/cpp0x/nsdmi13.C +++ gcc/testsuite/g++.dg/cpp0x/nsdmi13.C @@ -0,0 +1,13 @@ +// PR c++/79796 +// { dg-do compile { target c++11 } } + +struct A +{ + A* p = this; +}; + +void foo() +{ + A a; + a = A({}); +} Marek