From patchwork Wed Mar 16 19:54:45 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 87296 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 B8897B700A for ; Thu, 17 Mar 2011 06:54:59 +1100 (EST) Received: (qmail 14721 invoked by alias); 16 Mar 2011 19:54:58 -0000 Received: (qmail 14712 invoked by uid 22791); 16 Mar 2011 19:54:57 -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; Wed, 16 Mar 2011 19:54:49 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p2GJsmP7010345 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 16 Mar 2011 15:54:48 -0400 Received: from [127.0.0.1] (ovpn-113-145.phx2.redhat.com [10.3.113.145]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p2GJskbg013198 for ; Wed, 16 Mar 2011 15:54:46 -0400 Message-ID: <4D811585.2020106@redhat.com> Date: Wed, 16 Mar 2011 15:54:45 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.15) Gecko/20110307 Fedora/3.1.9-0.39.b3pre.fc14 Lightning/1.0b2 Thunderbird/3.1.9 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/48115 (ICE with ellipsis and templates) 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 the issue was that require_complete_type doesn't do anything in templates, but convert_arg_to_ellipsis was assuming that it did. The simple fix is to make sure we really do have a complete type. Tested x86_64-pc-linux-gnu, applying to trunk. Also OK for 4.6? The patch seems extremely safe. commit dbba5904d0fb00a0ddd934ee4c827592630c653e Author: Jason Merrill Date: Wed Mar 16 14:15:41 2011 -0400 PR c++/48115 * call.c (convert_arg_to_ellipsis): Handle incomplete type. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 388f46c..f75c248 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -5671,6 +5671,10 @@ convert_arg_to_ellipsis (tree arg) arg_type = TREE_TYPE (arg); if (arg != error_mark_node + /* In a template (or ill-formed code), we can have an incomplete type + even after require_complete_type, in which case we don't know + whether it has trivial copy or not. */ + && COMPLETE_TYPE_P (arg_type) && (type_has_nontrivial_copy_init (arg_type) || TYPE_HAS_NONTRIVIAL_DESTRUCTOR (arg_type))) { diff --git a/gcc/testsuite/g++.dg/template/incomplete6.C b/gcc/testsuite/g++.dg/template/incomplete6.C new file mode 100644 index 0000000..7138b6a --- /dev/null +++ b/gcc/testsuite/g++.dg/template/incomplete6.C @@ -0,0 +1,22 @@ +// PR c++/48115 + +template struct templ { }; + +template T declval(); + +typedef int (*F2)(...); + +template struct Int { }; + +template +struct S +{ + template + Int()(T()) )> + f(A); +}; + +int main() +{ + S >().f(0); +}