From patchwork Wed Nov 3 15:18:25 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 70013 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 919561007D2 for ; Thu, 4 Nov 2010 02:18:36 +1100 (EST) Received: (qmail 20223 invoked by alias); 3 Nov 2010 15:18:34 -0000 Received: (qmail 20211 invoked by uid 22791); 3 Nov 2010 15:18:32 -0000 X-SWARE-Spam-Status: No, hits=-6.1 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, 03 Nov 2010 15:18:28 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oA3FIQDl032715 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 3 Nov 2010 11:18:26 -0400 Received: from [127.0.0.1] ([10.3.113.16]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oA3FIPbu008298 for ; Wed, 3 Nov 2010 11:18:26 -0400 Message-ID: <4CD17D41.4060508@redhat.com> Date: Wed, 03 Nov 2010 11:18:25 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.14) Gecko/20101020 Lightning/1.0b1 Shredder/3.0.10pre MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/46277 (ICE in spec2k) 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 I'm a little concerned that we can't figure out which function is being called in this case, since it isn't actually type-dependent, but since this isn't in a constant expression it doesn't really matter. Tested x86_64-pc-linux-gnu, applied to trunk. commit 7d13a58f7e3d2e0fa70c58cab5bb73b206998c00 Author: Jason Merrill Date: Wed Nov 3 01:04:24 2010 -0400 PR c++/46277 * init.c (expand_default_init): Avoid ICE if we can't figure out which function is being called. diff --git a/gcc/cp/init.c b/gcc/cp/init.c index d632816..982dc24 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -1443,7 +1443,7 @@ expand_default_init (tree binfo, tree true_exp, tree exp, tree init, int flags, if (exp == true_exp && TREE_CODE (rval) == CALL_EXPR) { tree fn = get_callee_fndecl (rval); - if (DECL_DECLARED_CONSTEXPR_P (fn)) + if (fn && DECL_DECLARED_CONSTEXPR_P (fn)) { tree e = maybe_constant_value (rval); if (TREE_CONSTANT (e)) diff --git a/gcc/testsuite/g++.dg/template/new9.C b/gcc/testsuite/g++.dg/template/new9.C new file mode 100644 index 0000000..24e40ee --- /dev/null +++ b/gcc/testsuite/g++.dg/template/new9.C @@ -0,0 +1,16 @@ +// PR c++/46277 + +class ggRGBE { +public: + ggRGBE(); +}; +template class ggIO +{ + void readbody(int); + ggRGBE *scanline; +}; +template void +ggIO::readbody(int width) +{ + scanline = new ggRGBE[width]; +}