From patchwork Wed Mar 9 17:56:56 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 86149 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 2FEA6B6EFF for ; Thu, 10 Mar 2011 04:57:09 +1100 (EST) Received: (qmail 23394 invoked by alias); 9 Mar 2011 17:57:07 -0000 Received: (qmail 23384 invoked by uid 22791); 9 Mar 2011 17:57:05 -0000 X-SWARE-Spam-Status: No, hits=-6.2 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; Wed, 09 Mar 2011 17:56:58 +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 p29Huv2Z032365 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 9 Mar 2011 12:56:57 -0500 Received: from [127.0.0.1] (ovpn-113-58.phx2.redhat.com [10.3.113.58]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p29Huu6r003722 for ; Wed, 9 Mar 2011 12:56:57 -0500 Message-ID: <4D77BF68.1060002@redhat.com> Date: Wed, 09 Mar 2011 12:56:56 -0500 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101209 Fedora/3.1.7-0.35.b3pre.fc14 Lightning/1.0b2 Thunderbird/3.1.7 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/44629 (ICE with function template as non-type template argument) 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 In this testcase, we have a function template used as an argument for a function pointer template parameter. This causes unify to abort because an OVERLOAD doesn't satisfy EXPR_P. 14.8.2.5 lists an overloaded function given as a function argument as a non-deduced context, so it seems reasonable to treat one given as a template argument as non-deduced as well. The ABI is silent on how to mangle this, and EDG currently does something strange, so I'm not going to add mangling in 4.6; as a result, the testcase will get a sorry from the mangler, but that's better than an ICE. Tested x86_64-pc-linux-gnu, applied to trunk, 4.4, 4.5. commit 5faa2c811748d00cbee57ad0e5c991549099b95a Author: Jason Merrill Date: Tue Mar 8 21:44:29 2011 -0500 PR c++/44629 * pt.c (unify): An unresolved overload is a nondeduced context. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 2ca2cd0..ac91698 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -15688,6 +15688,9 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict) return 1; default: + /* An unresolved overload is a nondeduced context. */ + if (type_unknown_p (parm)) + return 0; gcc_assert (EXPR_P (parm)); /* We must be looking at an expression. This can happen with diff --git a/gcc/testsuite/g++.dg/template/nontype22.C b/gcc/testsuite/g++.dg/template/nontype22.C new file mode 100644 index 0000000..f2c8c46 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/nontype22.C @@ -0,0 +1,11 @@ +// PR c++/44629 +// The proper mangling is unclear. + +template int cmp1(T a, T b); +template struct A { }; +template void f (A &); // { dg-bogus "" "" { xfail *-*-* } } +void g() +{ + A a; + f(a); +}