From patchwork Fri Jun 14 13:22:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 1115969 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-502966-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.b="l+hNeXsW"; 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 45QLrG315Sz9sDX for ; Fri, 14 Jun 2019 23:22:36 +1000 (AEST) 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:mime-version :content-transfer-encoding; q=dns; s=default; b=Lr0K+smzfCn73tsW M6YWkeNd915cpQG44VaD16LbMAwaJ9L9Zay6pphQNE7p6JnemgVFzybLlw/PBFSn pkcFgWHhoefvxkvsX6aXGcny97pIEbr3BXsO5RIoUJiV7k1JttesHiRO6xKS981/ 630xnwCiUaOlEZxPRuB3oP/0zuY= 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:mime-version :content-transfer-encoding; s=default; bh=mPIVPYzJ6Q78hYuV2o/XYs yGOeQ=; b=l+hNeXsWuplqVIsf2HFr8iskw6K2CWYoIAZiW6IX65Y4l2j/Lk2d3r MalB5FCce0UGB7qXklUlhWmXWNFDuvwB/SzC0KBVy4zPXDLS2tDn/Djk/B0d/+QM Palb61WFl6sWL3SqQpeXIh5m1KRLX+eYv1MH0jLFBKckazXYvvVJI= Received: (qmail 80296 invoked by alias); 14 Jun 2019 13:22:29 -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 80287 invoked by uid 89); 14 Jun 2019 13:22:28 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.9 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=UD:typeck2.c, typeck2c, typeck2.c, HX-Received:ed0a X-HELO: mail-qk1-f179.google.com Received: from mail-qk1-f179.google.com (HELO mail-qk1-f179.google.com) (209.85.222.179) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 14 Jun 2019 13:22:27 +0000 Received: by mail-qk1-f179.google.com with SMTP id r6so1651654qkc.0 for ; Fri, 14 Jun 2019 06:22:27 -0700 (PDT) Received: from orpheus.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 j25sm540517qkk.53.2019.06.14.06.22.24 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 14 Jun 2019 06:22:24 -0700 (PDT) From: Jason Merrill To: gcc-patches@gcc.gnu.org Subject: [C++ PATCH] PR c++/85552 - wrong instantiation of dtor for DMI. Date: Fri, 14 Jun 2019 09:22:22 -0400 Message-Id: <20190614132222.26649-1-jason@redhat.com> MIME-Version: 1.0 X-IsSubscribed: yes The problem here is that when processing direct-initialization of a data member, we don't need to worry about destruction semantics; that will be handled in the [cd]tor. Conveniently, we already have tf_no_cleanup from a similar fix to new-expressions. Tested x86_64-pc-linux-gnu, applying to trunk. * typeck2.c (digest_nsdmi_init): Set tf_no_cleanup for direct-init. --- gcc/cp/typeck2.c | 5 +++- gcc/testsuite/g++.dg/cpp0x/nsdmi-list5.C | 30 ++++++++++++++++++++++++ gcc/cp/ChangeLog | 5 ++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/nsdmi-list5.C base-commit: 2ab89918e26a3999ec1df110d45464cf7489fe88 diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index 0109d6e52f5..e8627dd38c0 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -1309,7 +1309,10 @@ digest_nsdmi_init (tree decl, tree init, tsubst_flags_t complain) tree type = TREE_TYPE (decl); int flags = LOOKUP_IMPLICIT; if (DIRECT_LIST_INIT_P (init)) - flags = LOOKUP_NORMAL; + { + flags = LOOKUP_NORMAL; + complain |= tf_no_cleanup; + } if (BRACE_ENCLOSED_INITIALIZER_P (init) && CP_AGGREGATE_TYPE_P (type)) init = reshape_init (type, init, complain); diff --git a/gcc/testsuite/g++.dg/cpp0x/nsdmi-list5.C b/gcc/testsuite/g++.dg/cpp0x/nsdmi-list5.C new file mode 100644 index 00000000000..a12740b23b0 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nsdmi-list5.C @@ -0,0 +1,30 @@ +// PR c++/85552 +// { dg-do compile { target c++11 } } + +template +struct uptr { + uptr() { } + uptr(void*) { } + ~uptr() { static_assert(sizeof(T), "complete type"); } +}; + +class S; + +class Compiles +{ + uptr s; +}; + +class DoesntCompile +{ + ~DoesntCompile(); + DoesntCompile(); + + uptr s1 { }; + uptr s2 { nullptr }; +}; + +int main() +{ + return 0; +} diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c6823b57aa7..62e541736ec 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2019-06-12 Jason Merrill + + PR c++/85552 - wrong instantiation of dtor for DMI. + * typeck2.c (digest_nsdmi_init): Set tf_no_cleanup for direct-init. + 2019-06-13 Paolo Carlini * decl.c (grokdeclarator): Use id_loc in five additional places