From patchwork Thu Jan 3 18:31:28 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 209296 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 E261A2C0086 for ; Fri, 4 Jan 2013 05:31:49 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1357842710; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=5OP04Mq GqrVL8UUd8yU0P8r8yt0=; b=Wx0nwP59jN5drf55f8FWR8sXZspkKIpiJ76cckV pIoQB2GaLowuLADv9xqjkaEKkgdo0TgwBz7y20+7lHr36x4RezlVR/uYRSZaVsP7 NU2Ddqt6p8ZXTJUXdm/qPW1k2H5hPVIVUySGLxtnYGHENpUr/OX/DaMUqWbEf+Ht 8u78= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=I2qe3prrthz8pR5zUzceotL08RrDXWX5HHdfPDz9W1X2F05u+ZAU8B1BHmf3Wg wUrGhzge9odaBbD9aYjgO3ARq2qHKO5WhJLTL1PeFb02TNwn1d4VULRz8Th1yqRc XeplNaQunJRaGCVzFwXCis01LGiLWJurS81TInAoPIGt0=; Received: (qmail 30893 invoked by alias); 3 Jan 2013 18:31:37 -0000 Received: (qmail 30856 invoked by uid 22791); 3 Jan 2013 18:31:36 -0000 X-SWARE-Spam-Status: No, hits=-6.2 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, KHOP_SPAMHAUS_DROP, 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; Thu, 03 Jan 2013 18:31:30 +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.14.4/8.14.4) with ESMTP id r03IVTxw027998 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 3 Jan 2013 13:31:29 -0500 Received: from [10.3.113.59] (ovpn-113-59.phx2.redhat.com [10.3.113.59]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r03IVTNV029918 for ; Thu, 3 Jan 2013 13:31:29 -0500 Message-ID: <50E5CE80.9010205@redhat.com> Date: Thu, 03 Jan 2013 13:31:28 -0500 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/55856 (ICE with tuple of reference) 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 the original testcase, the constexpr code was getting confused by a DECL_EXPR for a lifetime-extended temporary bound to the reference member of the tuple. Tested x86_64-pc-linux-gnu, applying to trunk and 4.7. commit e9f73b2b5a67a425ae52755a6f9bebe16fc2398d Author: Jason Merrill Date: Thu Jan 3 13:16:14 2013 -0500 PR c++/55856 * semantics.c (build_data_member_initialization): Handle DECL_EXPR. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index f649399..9f8119f 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -5848,15 +5848,19 @@ build_data_member_initialization (tree t, vec **vec) member = TREE_OPERAND (t, 0); init = unshare_expr (TREE_OPERAND (t, 1)); } - else + else if (TREE_CODE (t) == CALL_EXPR) { - gcc_assert (TREE_CODE (t) == CALL_EXPR); member = CALL_EXPR_ARG (t, 0); /* We don't use build_cplus_new here because it complains about abstract bases. Leaving the call unwrapped means that it has the wrong type, but cxx_eval_constant_expression doesn't care. */ init = unshare_expr (t); } + else if (TREE_CODE (t) == DECL_EXPR) + /* Declaring a temporary, don't add it to the CONSTRUCTOR. */ + return true; + else + gcc_unreachable (); if (TREE_CODE (member) == INDIRECT_REF) member = TREE_OPERAND (member, 0); if (TREE_CODE (member) == NOP_EXPR) diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor11.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor11.C new file mode 100644 index 0000000..4b526ea --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-ctor11.C @@ -0,0 +1,16 @@ +// PR c++/55856 +// { dg-options -std=c++11 } + +struct A +{ + A(const char *); +}; + +template +struct B +{ + T t; + template constexpr B(U&& u): t(u) { }; +}; + +B b("");