From patchwork Thu Jan 16 22:39:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 1224482 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-517550-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha1 header.s=default header.b=Wa2+SNtc; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=J0ci7a09; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47zJzT127Tz9sP3 for ; Fri, 17 Jan 2020 09:39:48 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:content-type :content-transfer-encoding; q=dns; s=default; b=Xtsp3CN/sX1IrFKH VPHRFkJo3v9PLw96GsOrZq+aHWUA5jgn+Aa+S20TScTCYaQJUPEtyLwP0GC9F3rF zlR6w+ljfUKJYzxuCi9YF8A8h2WekCT8+K+rb24+9Uf7c3gIJd/KMkmgj6rP6Hdy 6/W6XW+LCKyiLQ7kThrN37Ec4Uc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:content-type :content-transfer-encoding; s=default; bh=0z7zictOxVRsUwKI1BCAtr LZ4dw=; b=Wa2+SNtcSN61dkTPCKDcbeA8VTT+1Jwnu7XkJvJEyuIHp8Y0nyn9Qz ssq774Z903NPWQOeyr2XoS2AC53tkHNNTgNLcHcata2PvNsfLw2D150SR8vU5P2c ayHtzDUNQgy6R0NtzjYs6EwZC4c4MR0ddCzGkGrNPaUidytivm8yw= Received: (qmail 15267 invoked by alias); 16 Jan 2020 22:39:41 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 13997 invoked by uid 89); 16 Jan 2020 22:39:40 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-19.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy= X-HELO: us-smtp-1.mimecast.com Received: from us-smtp-delivery-1.mimecast.com (HELO us-smtp-1.mimecast.com) (207.211.31.120) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 16 Jan 2020 22:39:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579214378; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=HUP96VKarrb8qBLl0Rsi5j27XATsJBqiLU8jOWBCc8I=; b=J0ci7a098GAUCprx7tL+FvjiQnj4z8dPXYcMahrOVuchXTItl1ede391ZmpL+nKSdsGZub EOKJHP3VyLCB34zMjR73x95u8oTt00ypZ8/w5Zy0trjxqheuQF1koD6wlYK2b8/gfqcUwx AexzdiDRfJVRBTN6lNJUUu6LHg3zFZ4= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-131-NDsOpIPhORy04rmAHfB_5A-1; Thu, 16 Jan 2020 17:39:36 -0500 Received: by mail-qt1-f198.google.com with SMTP id e1so14746710qto.5 for ; Thu, 16 Jan 2020 14:39:36 -0800 (PST) Received: from barrymore.redhat.com (209-6-216-142.s141.c3-0.smr-cbr1.sbo-smr.ma.cable.rcncustomer.com. [209.6.216.142]) by smtp.gmail.com with ESMTPSA id s26sm12237434qtc.43.2020.01.16.14.39.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jan 2020 14:39:34 -0800 (PST) From: Jason Merrill To: gcc-patches@gcc.gnu.org Subject: [C++ PATCH] PR c++/93280 - ICE with aggregate assignment and DMI. Date: Thu, 16 Jan 2020 17:39:33 -0500 Message-Id: <20200116223933.2355-1-jason@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-IsSubscribed: yes I recently added an assert to cp-gimplify to catch any TARGET_EXPR_DIRECT_INIT_P being expanded without a target object, and this testcase found one. We started out with a TARGET_EXPR around the CONSTRUCTOR, which would normally mean that the member initializer would be used to directly initialize the appropriate member of whatever object the TARGET_EXPR ends up initializing. But then gimplify_modify_expr_rhs stripped the TARGET_EXPR in order to assign directly from the elements of the CONSTRUCTOR, leaving no object for the TARGET_EXPR_DIRECT_INIT_P to initialize. I considered setting CONSTRUCTOR_PLACEHOLDER_BOUNDARY in that case, which implies TARGET_EXPR_NO_ELIDE, but decided that there's no particular reason the A initializer needs to initialize a member of a B rather than a distinct A object, so let's only set TARGET_EXPR_DIRECT_INIT_P when we're using the DMI in a constructor. Tested x86_64-pc-linux-gnu, applying to trunk. * init.c (get_nsdmi): Set TARGET_EXPR_DIRECT_INIT_P here. * typeck2.c (digest_nsdmi_init): Not here. --- gcc/cp/init.c | 4 ++++ gcc/cp/typeck2.c | 3 --- 2 files changed, 4 insertions(+), 3 deletions(-) base-commit: 98d56ea8900fdcff8f1987cf2bf499a5b7399857 diff --git a/gcc/cp/init.c b/gcc/cp/init.c index ba80474e6ac..543d127abcd 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -655,6 +655,10 @@ get_nsdmi (tree member, bool in_ctor, tsubst_flags_t complain) if (simple_target) init = TARGET_EXPR_INITIAL (init); init = break_out_target_exprs (init, /*loc*/true); + if (in_ctor && init && TREE_CODE (init) == TARGET_EXPR) + /* This expresses the full initialization, prevent perform_member_init from + calling another constructor (58162). */ + TARGET_EXPR_DIRECT_INIT_P (init) = true; if (simple_target && TREE_CODE (init) != CONSTRUCTOR) /* Now put it back so C++17 copy elision works. */ init = get_target_expr (init); diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index f36a5649ae6..371b203c29b 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -1369,9 +1369,6 @@ digest_nsdmi_init (tree decl, tree init, tsubst_flags_t complain) && CP_AGGREGATE_TYPE_P (type)) init = reshape_init (type, init, complain); init = digest_init_flags (type, init, flags, complain); - if (TREE_CODE (init) == TARGET_EXPR) - /* This represents the whole initialization. */ - TARGET_EXPR_DIRECT_INIT_P (init) = true; return init; }