From patchwork Wed Jan 29 22:11:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 315237 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id AF88E2C007C for ; Thu, 30 Jan 2014 09:11:19 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=fR7frCMHZB7/LFaYkb1IdlWMnMucaa3IJN2U1IShkFsetj oOBDS8FTbuBfUpfxnFN/5ouc9RTgFoI8xYLhr23j+buuunc3IrrlEHVAN4/rz4mr iXqVS2Mpj919e6wASTD3ufoDLZn8niIrJjNNT5y67pQbEVv/Q6ylazNLZ4M7c= 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 :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=QpjmkCn2V/chgWiN7AR8m1wq92I=; b=etjSHZU45lqG3zTUgkDt dTGx1NsPVVX8NaWclxT0uOC5+k2n05C/HJVJtnuZ8Nphrd51XM6HhmvnwzgaTJ1P YEGTXuPEXoojP2TSjT0JJVe69nV3Y+j4dFM9gAiWh0q/DaXFdAToUpXcC6xbfjJa jM49LqF5a3rhdvr1EY4ZaPc= Received: (qmail 25754 invoked by alias); 29 Jan 2014 22:11:12 -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 25743 invoked by uid 89); 29 Jan 2014 22:11:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.3 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 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; Wed, 29 Jan 2014 22:11:10 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s0TMB94m005120 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 29 Jan 2014 17:11:09 -0500 Received: from [10.10.116.22] ([10.10.116.22]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s0TMB7up011919 for ; Wed, 29 Jan 2014 17:11:08 -0500 Message-ID: <52E97C7A.2030605@redhat.com> Date: Wed, 29 Jan 2014 17:11:06 -0500 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/59989 (ICE with variadics) We counted the pack and all the elements of the pack, giving us a final count one too high. Tested x86_64-pc-linux-gnu, applying to trunk and 4.8. commit b75c08746dc30ac50e908e8d520042f4157281f9 Author: Jason Merrill Date: Wed Jan 29 16:41:23 2014 -0500 PR c++/59989 * pt.c (expand_template_argument_pack): Correct non_default_args_count calculation. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 9be9171..c9c6b37 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -3471,7 +3471,7 @@ expand_template_argument_pack (tree args) for (i = 0; i < num_packed; ++i, ++out_arg) TREE_VEC_ELT (result_args, out_arg) = TREE_VEC_ELT(packed, i); if (non_default_args_count > 0) - non_default_args_count += num_packed; + non_default_args_count += num_packed - 1; } else { diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic148.C b/gcc/testsuite/g++.dg/cpp0x/variadic148.C new file mode 100644 index 0000000..a4ee635 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic148.C @@ -0,0 +1,6 @@ +// PR c++/59989 +// { dg-require-effective-target c++11 } + +template struct X {}; +template class D, typename ...U> int test(D*); +int n = test(0); // { dg-error "no match" }