From patchwork Tue Oct 18 19:08:13 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 120490 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 00D64B70C6 for ; Wed, 19 Oct 2011 06:08:36 +1100 (EST) Received: (qmail 15462 invoked by alias); 18 Oct 2011 19:08:33 -0000 Received: (qmail 15451 invoked by uid 22791); 18 Oct 2011 19:08:32 -0000 X-SWARE-Spam-Status: No, hits=-6.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 18 Oct 2011 19:08:16 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p9IJ8Gdc018418 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 18 Oct 2011 15:08:16 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p9IJ8F8D028264 for ; Tue, 18 Oct 2011 15:08:15 -0400 Received: from [0.0.0.0] (ovpn-113-91.phx2.redhat.com [10.3.113.91]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id p9IJ8EVe031204 for ; Tue, 18 Oct 2011 15:08:14 -0400 Message-ID: <4E9DCE9D.1060504@redhat.com> Date: Tue, 18 Oct 2011 15:08:13 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:7.0.1) Gecko/20111001 Thunderbird/7.0.1 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/50531 (ICE with template dtor defaulted outside fn) 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 Here we were failing to recognize that a defaulted fn had already been instantiated, and crashed trying to instantiate it again. Tested x86_64-pc-linux-gnu, applying to trunk and 4.6. commit 10ff48cb9f7817ae8e95e71bd4b22989dafb2be2 Author: Jason Merrill Date: Tue Oct 18 14:25:42 2011 -0400 PR c++/50531 * pt.c (instantiate_decl): Recognize when a function defaulted outside the class is already instantiated. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 6fc60d5..56fa632 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -18045,6 +18045,8 @@ instantiate_decl (tree d, int defer_ok, d = DECL_CLONED_FUNCTION (d); if (DECL_TEMPLATE_INSTANTIATED (d) + || (TREE_CODE (d) == FUNCTION_DECL + && DECL_DEFAULTED_FN (d) && DECL_INITIAL (d)) || DECL_TEMPLATE_SPECIALIZATION (d)) /* D has already been instantiated or explicitly specialized, so there's nothing for us to do here. diff --git a/gcc/testsuite/g++.dg/cpp0x/defaulted32.C b/gcc/testsuite/g++.dg/cpp0x/defaulted32.C new file mode 100644 index 0000000..351cdae --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/defaulted32.C @@ -0,0 +1,21 @@ +// PR c++/50531 +// { dg-options -std=c++0x } + +template +class DataFilter +{ + public: + inline virtual ~DataFilter(); +}; + +template +inline DataFilter::~DataFilter() = default; + +class ARCalculator : public DataFilter +{ + public: + virtual void dataStart(int, int); +}; + +void ARCalculator::dataStart(int, int) +{}