From patchwork Tue May 10 18:29:10 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 95109 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 81BFA1007F3 for ; Wed, 11 May 2011 17:56:14 +1000 (EST) Received: (qmail 19783 invoked by alias); 10 May 2011 18:29:29 -0000 Received: (qmail 19759 invoked by uid 22791); 10 May 2011 18:29:29 -0000 X-SWARE-Spam-Status: No, hits=-6.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, T_RP_MATCHES_RCVD 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, 10 May 2011 18:29:12 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p4AITBQi018792 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 10 May 2011 14:29:11 -0400 Received: from [127.0.0.1] (ovpn-113-60.phx2.redhat.com [10.3.113.60]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p4AITBOY031525 for ; Tue, 10 May 2011 14:29:11 -0400 Message-ID: <4DC983F6.3030204@redhat.com> Date: Tue, 10 May 2011 14:29:10 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.15) Gecko/20110421 Fedora/3.1.9-2.fc14 Lightning/1.0b2 Thunderbird/3.1.9 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/48736 (crash with default template argument involving pack expansion) 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 tsubst_copy_and_build was assuming that substituting into a pack expansion would always produce a vector of elements, which is not true if the template arguments are still dependent. Tested x86_64-pc-linux-gnu, applied to trunk. commit 3bc57a5e66cd7a4e6e9a77900249db0bf193456b Author: Jason Merrill Date: Mon May 9 17:13:55 2011 -0400 PR c++/48736 * pt.c (tsubst_copy_and_build): Handle substitution of a pack expansion producing another expansion. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index f6392d6..5e24977 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -13250,7 +13250,8 @@ tsubst_copy_and_build (tree t, ce->value = tsubst_pack_expansion (ce->value, args, complain, in_decl); - if (ce->value == error_mark_node) + if (ce->value == error_mark_node + || PACK_EXPANSION_P (ce->value)) ; else if (TREE_VEC_LENGTH (ce->value) == 1) /* Just move the argument into place. */ diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic108.C b/gcc/testsuite/g++.dg/cpp0x/variadic108.C new file mode 100644 index 0000000..3ad5af4 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic108.C @@ -0,0 +1,10 @@ +// PR c++/48736 +// { dg-options -std=c++0x } + +template +T&& create(); + +template()...}) // Line X +> +char f(int);