From patchwork Mon Feb 21 05:05:20 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 83777 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 84AF1B7193 for ; Mon, 21 Feb 2011 16:05:38 +1100 (EST) Received: (qmail 643 invoked by alias); 21 Feb 2011 05:05:34 -0000 Received: (qmail 624 invoked by uid 22791); 21 Feb 2011 05:05:32 -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; Mon, 21 Feb 2011 05:05:23 +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 p1L55LGE021967 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 21 Feb 2011 00:05:21 -0500 Received: from [127.0.0.1] (ovpn-113-43.phx2.redhat.com [10.3.113.43]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p1L55Kbj016685 for ; Mon, 21 Feb 2011 00:05:21 -0500 Message-ID: <4D61F290.1040203@redhat.com> Date: Mon, 21 Feb 2011 00:05:20 -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: Re: C++ PATCH for c++/47503 (C++0x ICE with trivial copy constructor and -fno-elide-constructors) References: <4D60AD36.9010401@redhat.com> In-Reply-To: <4D60AD36.9010401@redhat.com> 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 But we still need to force constant evaluation of the result of convert_from_reference. Tested x86_64-pc-linux-gnu, applied to trunk. commit a2889f0e13dd03b318cb2f60d2529d5adc57e07f Author: Jason Merrill Date: Sun Feb 20 21:23:58 2011 -0500 PR c++/47199 * semantics.c (cxx_eval_call_expression): Call cxx_eval_constant_expression in trivial shortcut. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 8944690..b7ed525 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -6021,7 +6021,11 @@ cxx_eval_call_expression (const constexpr_call *old_call, tree t, /* Shortcut trivial copy constructor/op=. */ if (call_expr_nargs (t) == 2 && trivial_fn_p (fun)) - return convert_from_reference (get_nth_callarg (t, 1)); + { + tree arg = convert_from_reference (get_nth_callarg (t, 1)); + return cxx_eval_constant_expression (old_call, arg, allow_non_constant, + addr, non_constant_p); + } /* If in direct recursive call, optimize definition search. */ if (old_call != NULL && old_call->fundef->decl == fun) diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor7.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor7.C new file mode 100644 index 0000000..8338bf1 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor7.C @@ -0,0 +1,17 @@ +// PR c++/47199 +// { dg-options "-std=c++0x -fno-elide-constructors" } + +template < int > struct S +{ + constexpr S (int r):rr (r) + { + } + S (const S &) = default; + static constexpr S s () + { + return -1; + } + int rr; +}; + +static const int d = S < 0 >::s ().rr;