From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5251 invoked by alias); 23 Nov 2016 23:31:23 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 5228 invoked by uid 89); 23 Nov 2016 23:31:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=1.3 required=5.0 tests=AWL,BAYES_50,SPF_HELO_PASS,SPF_SOFTFAIL autolearn=no version=3.3.2 spammy=baldwin, Baldwin, assigning, wwwibmcom X-HELO: mail.baldwin.cx Received: from bigwig.baldwin.cx (HELO mail.baldwin.cx) (96.47.65.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 23 Nov 2016 23:31:11 +0000 Received: from ralph.baldwin.cx (c-73-231-226-104.hsd1.ca.comcast.net [73.231.226.104]) by mail.baldwin.cx (Postfix) with ESMTPSA id 2F3C310A9D7; Wed, 23 Nov 2016 18:31:10 -0500 (EST) From: John Baldwin To: Simon Marchi Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 3/3] Do not use std::move when assigning an anonymous object to a unique_ptr. Date: Wed, 23 Nov 2016 23:31:00 -0000 Message-ID: <1950124.hOhKlgFiTt@ralph.baldwin.cx> User-Agent: KMail/4.14.10 (FreeBSD/11.0-PRERELEASE; KDE/4.14.10; amd64; ; ) In-Reply-To: References: <20161123200652.89209-1-jhb@FreeBSD.org> <20161123200652.89209-4-jhb@FreeBSD.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-IsSubscribed: yes X-SW-Source: 2016-11/txt/msg00737.txt.bz2 On Wednesday, November 23, 2016 04:19:29 PM Simon Marchi wrote: > On 2016-11-23 15:06, John Baldwin wrote: > > Using std::move forces an extra copy of the object. These changes fix > > -Wpessimizing-move warnings from clang. > > For those who, like me, do not quite understand what is happening here, > I suggest the following read: > > https://www.ibm.com/developerworks/community/blogs/5894415f-be62-4bc0-81c5-3956e82276f3/entry/RVO_V_S_std_move?lang=en My head also hurts. I think what clang is warning about is that the std::move() in these lines breaks RVO for the function being called, not the function that the modified line belongs to. That is: foo = bar (); Is able to do RVO if bar() does the right things for RVO to work. However: foo = std::move (bar ()); forces an extra copy of the object since the return value of bar can't use the storge of 'foo' directly, it has to be copied into an anonymous object (I think) for std::move to consume. The commit log for the warning is here: http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20150427/128053.html I think these instances fall under the "using a move to create a new object from a temporary object" case. -- John Baldwin