Boost logo

Boost :

From: Daniel Frey (daniel.frey_at_[hidden])
Date: 2002-06-28 11:05:04


"Victor A. Wagner, Jr." wrote:
>
> "missed"? Unnamed return value optimization has been around longer.
> Scott Meyers (I left his books at the office, so I can't quote which)
> talked at length about why naming the temporary was likely to generate
> WORSE code on most (at the time he wrote it) compilers.

It's "More Efficient C++", Item 4.7. Please also read the errata,
available at Scott's website. I haven't seen a single case where a
compiler optimized away any of the unnamed return values for all the
relevant tests (see csc++). I checked this for GCC 2.95.2, GCC 2.95.3,
GCC 3.0.4, GCC 3.1, TenDRA 4.1.2, KAI CC (1 year ago, don't remember the
version), Sun's CC and IIRC the HP-compiler (version: see KAI CC).
Before the GCC 3.1, it made no difference for me as all compilers I know
of didn't optimized the return value. With GCC 3.1, things changed and
it was the first time I was able to remove the temporary with standard
C++. The GCC 2.95.x had a special extension, which allowed something
similar, but that was not portable. Still I'd like to hear about a
single compiler that actually performs the RVO for Scott's example...
(and from the thread in csc++, it isn't clear if it is allowed to be
optimized :)

Regards, Daniel

--
Daniel Frey
aixigo AG - financial training, research and technology
Schloß-Rahe-Straße 15, 52072 Aachen, Germany
fon: +49 (0)241 936737-42, fax: +49 (0)241 936737-99
eMail: daniel.frey_at_[hidden], web: http://www.aixigo.de

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk