From patchwork Thu Feb 14 22:43:24 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 220538 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 35DDB2C0079 for ; Fri, 15 Feb 2013 09:43:43 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1361486624; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=P7Le0z/ M2wnQh0OlZMwSR8ViiLo=; b=ek2HfpACFOQZZ2ZhZN+WIaK/9gvmAGGmvkO17qN qzGUwMx7mOEHukfMzOSiFmphHCIlP6tdPda9KZ9PdoL8FiD733bYp6v3unvBEJXi B6J2lDIYV8By3iyPVO3fTg4fkUJ4n2OQwLyRu9oj6BLCEnG/xOYgYfRO0WZhPzb3 JBDc= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=BbxV3VcxH04RgOYq4Y5CIlUO3zH1w5rrFYlNo1H7Wi4ro+1UHpfG+gvZrYegcB gUzcB3A2SJC4P9SDXNB1p2DMi1WkcUc+YbryLTxUIVlzpPZGrYSOpzIwU8k595PR S/8jctxVgL9oRKvF1QOx5XxHkQVy0qtV0QOrztdGOTtQA=; Received: (qmail 9108 invoked by alias); 14 Feb 2013 22:43:37 -0000 Received: (qmail 9098 invoked by uid 22791); 14 Feb 2013 22:43:37 -0000 X-SWARE-Spam-Status: No, hits=-6.3 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, KHOP_SPAMHAUS_DROP, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, 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; Thu, 14 Feb 2013 22:43:31 +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 r1EMhVnN006495 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 14 Feb 2013 17:43:31 -0500 Received: from [10.3.113.52] (ovpn-113-52.phx2.redhat.com [10.3.113.52]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r1EMhThD026216 for ; Thu, 14 Feb 2013 17:43:30 -0500 Message-ID: <511D688C.7030104@redhat.com> Date: Thu, 14 Feb 2013 17:43:24 -0500 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:21.0) Gecko/20100101 Thunderbird/21.0a1 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/55220 (ICE with non-deducible parameter pack) 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 This testcase is well-formed, even though it doesn't do what the user was trying to accomplish. In Tuple the use of a pack expansion not at the end of the list makes the whole argument list a non-deduced context, so we should get out early before it confuses us. Tested x86_64-pc-linux-gnu, applying to trunk. commit 48b50b5ac0b2f36d6b2f00c51862fe5461119eca Author: Jason Merrill Date: Thu Feb 14 12:00:30 2013 -0500 PR c++/55220 * pt.c (unify): A pack expansion that is not the last template argument makes the entire template argument list non-deduced. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index e88ea85..440df1e 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -16548,6 +16548,14 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict, && PACK_EXPANSION_P (TREE_VEC_ELT (parmvec, len - 1))) parm_variadic_p = 1; + for (i = 0; i < len - parm_variadic_p; ++i) + /* If the template argument list of P contains a pack + expansion that is not the last template argument, the + entire template argument list is a non-deduced + context. */ + if (PACK_EXPANSION_P (TREE_VEC_ELT (parmvec, i))) + return unify_success (explain_p); + if (TREE_VEC_LENGTH (argvec) < len - parm_variadic_p) return unify_too_few_arguments (explain_p, TREE_VEC_LENGTH (argvec), len); diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-nondeduce2.C b/gcc/testsuite/g++.dg/cpp0x/variadic-nondeduce2.C new file mode 100644 index 0000000..a82a098 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-nondeduce2.C @@ -0,0 +1,25 @@ +// PR c++/55220 +// { dg-do compile { target c++11 } } + +template struct something_like_tuple +{ + +}; + +template struct is_last +{ + static const bool value = false; +}; + +// Head is non-deducible, so this can't work as the user intended +template class Tuple, typename ... Head> +struct is_last> +{ + static const bool value = true; +}; + +#define SA(X) static_assert (X, #X) + +typedef something_like_tuple something_like_tuple_t; +SA ((is_last::value == false)); +SA ((is_last::value == false));