From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6164 invoked by alias); 11 Oct 2017 17:49:59 -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 5838 invoked by uid 89); 11 Oct 2017 17:49:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 spammy=H*Ad:U*uweigand, Hx-languages-length:1126 X-HELO: mailapp01.imgtec.com Received: from mailapp01.imgtec.com (HELO mailapp01.imgtec.com) (195.59.15.196) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 11 Oct 2017 17:49:58 +0000 Received: from HHMAIL01.hh.imgtec.org (unknown [10.100.10.19]) by Forcepoint Email with ESMTPS id EDD84CD3523D3; Wed, 11 Oct 2017 18:49:51 +0100 (IST) Received: from [10.20.78.183] (10.20.78.183) by HHMAIL01.hh.imgtec.org (10.100.10.21) with Microsoft SMTP Server id 14.3.361.1; Wed, 11 Oct 2017 18:49:54 +0100 Date: Wed, 11 Oct 2017 17:49:00 -0000 From: "Maciej W. Rozycki" To: Simon Marchi CC: Joel Brobecker , Ulrich Weigand , Subject: Re: [RFC][13/19] Target FP: Perform Ada fixed-point scaling in target format In-Reply-To: <4543871f-9a5a-5722-b868-706948b3f3ad@simark.ca> Message-ID: References: <20171009163008.5svu3sjyeubqaux7@adacore.com> <20171009165830.1607ED83320@oc3748833570.ibm.com> <20171009180952.xzg36frnnumvkrt5@adacore.com> <4543871f-9a5a-5722-b868-706948b3f3ad@simark.ca> User-Agent: Alpine 2.00 (DEB 1167 2008-08-23) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" X-SW-Source: 2017-10/txt/msg00304.txt.bz2 On Mon, 9 Oct 2017, Simon Marchi wrote: > > Let's wait for people who really know better about C++ to tell us > > whether it makes a difference. I was amazed as how careful you have > > to be when using C++ to avoid inefficiencies, but perhaps I am simply > > being paranoid in this case... That's why I tried to phrase this as > > a question. > > > > Indeed, it's preferable to use > > std::string foo = returns_string (); > > than > > std::string foo; > foo = returns_string (); > > The reason being that in the second case, the default constructor (the > one with no params) is called to construct an empty string, and then that > work is scrapped because we assign a new value. The first form constructs > the string right away with the right content. Hmm, wouldn't a half-decent compiler notice that the result produced by the default constructor is discarded and optimise the call away? Also has there actually been an assertion in (the current definition of C++) that all declared objects have also been initialised? Maciej the curious