From patchwork Tue Mar 10 17:43:55 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 448649 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 37B62140172 for ; Wed, 11 Mar 2015 04:44:22 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass reason="1024-bit key; unprotected key" header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=clkkJJw7; dkim-adsp=none (unprotected policy); dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=lRhs/DcLcOZbcMCeFoRYkbw3tSyFZdXe4JI/K2lln4wZ2xSuXxuV9 /OSNDzpOOGENgAqquDsUufwYj1m0wZJYg0SJwne3uhfg6xKhPUnVhhnZAnNeZVXe +DpsgQ8xf/fCaPBWPpsZ3qbGVhe9Un5DAIeClQPBmlR/UTpVD1OEcA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=EUtdoBmE0EzUZTVSoreUf0wtpcs=; b=clkkJJw7SHGJKY+7Y7L0 tV++WyIltjFxgY5GOAKlc8fOckTwYlTXiF5iK1ktLSLycxnVuEHr2LZ0LyICjzYw /tec4UjCyk/I3gmRSIOUYEMUU0c9vmdffZSs/ZsRm4Kop/5pmXSK9MjZ/4rrLxPj tSkVrAA5UREYJ6q+5Sn2MwI= Received: (qmail 31455 invoked by alias); 10 Mar 2015 17:44:00 -0000 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 Received: (qmail 31396 invoked by uid 89); 10 Mar 2015 17:43:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Tue, 10 Mar 2015 17:43:58 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t2AHhuS8012502 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Tue, 10 Mar 2015 13:43:57 -0400 Received: from localhost (ovpn-116-110.ams2.redhat.com [10.36.116.110]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t2AHhtjF019166 for ; Tue, 10 Mar 2015 13:43:56 -0400 Date: Tue, 10 Mar 2015 17:43:55 +0000 From: Jonathan Wakely To: gcc-patches@gcc.gnu.org Subject: [wwwdocs] Document C++ DR 1579 in /gcc-5/porting_to.html Message-ID: <20150310174355.GA13455@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) This change shouldn't cause many porting headaches, but it did cause one package to fail to build (due to a bug in the package), so it's worth documenting. Committed to CVS. Index: porting_to.html =================================================================== RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-5/porting_to.html,v retrieving revision 1.5 diff -u -r1.5 porting_to.html --- porting_to.html 18 Feb 2015 13:41:12 -0000 1.5 +++ porting_to.html 10 Mar 2015 17:37:15 -0000 @@ -385,6 +385,38 @@ It is recommended to use true, resp. false keywords in such cases. +

Return by converting move constructor

+ +

GCC 5 implements +DR 1579 +which means that in a function like:

+ +

+  X
+  foo()
+  {
+    Y y;
+    return y;
+  }
+
+ +

GCC will first attempt to construct the return value as if y +were an rvalue, and if that fails then it will try again for an lvalue +(all C++11 compilers already do this when returning a variable of the +same type as the function returns, but now they are required to do it +when the types are not the same). +This will change the constructor that gets called in some cases, +for example it might now call X(Y&&) instead of +X(const Y&). +

+

+In most cases the only observable difference will be code that runs faster +(by moving instead of copying) but if it causes a problem the new behavior +can be prevented by ensuring the compiler treats y as an lvalue, +using return X(y); or +return static_cast<Y&>(y);. +

+

Links