From patchwork Thu Sep 16 00:00:41 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 64929 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 88D6AB6F07 for ; Thu, 16 Sep 2010 10:00:56 +1000 (EST) Received: (qmail 16200 invoked by alias); 16 Sep 2010 00:00:55 -0000 Received: (qmail 16192 invoked by uid 22791); 16 Sep 2010 00:00:54 -0000 X-SWARE-Spam-Status: No, hits=-6.0 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, TW_NV, 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; Thu, 16 Sep 2010 00:00:50 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o8G00m7d020606 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 15 Sep 2010 20:00:48 -0400 Received: from [127.0.0.1] ([10.3.113.13]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o8G00fX5026795 for ; Wed, 15 Sep 2010 20:00:44 -0400 Message-ID: <4C915E29.4020403@redhat.com> Date: Wed, 15 Sep 2010 20:00:41 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.12) Gecko/20100912 Lightning/1.0b1 Shredder/3.0.8pre MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH to type of reference temporaries 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 While working on a constexpr bug, I noticed that we were giving the wrong type to the underlying temporaries for references. They should have the underlying type of the reference, not the type of the initializer. Tested x86_64-pc-linux-gnu, applied to trunk. commit 862fc9f3493ea633557772a36ebb446e740d9711 Author: Jason Merrill Date: Wed Sep 15 14:06:42 2010 -0400 * call.c (convert_like_real): Use the underlying type of the reference for the temporary. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 37c6269..2b9b848 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -5207,10 +5207,16 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum, || TREE_CODE (expr) == CONSTRUCTOR || TREE_CODE (expr) == VA_ARG_EXPR) { - tree type = convs->u.next->type; + /* Otherwise, a temporary of type "cv1 T1" is created and + initialized from the initializer expression using the rules + for a non-reference copy-initialization (8.5). */ + + tree type = TREE_TYPE (ref_type); cp_lvalue_kind lvalue = real_lvalue_p (expr); - if (!CP_TYPE_CONST_NON_VOLATILE_P (TREE_TYPE (ref_type)) + gcc_assert (same_type_ignoring_top_level_qualifiers_p + (type, convs->u.next->type)); + if (!CP_TYPE_CONST_NON_VOLATILE_P (type) && !TYPE_REF_IS_RVALUE (ref_type)) { if (complain & tf_error)