Topic: NRVO
Author: Christian.Theis@nospam.cern.ch ("Chris Theis")
Date: Sat, 16 Oct 2004 19:16:35 GMT Raw View
"Rob Williscroft" <rtw@freenet.co.uk> schrieb im Newsbeitrag
news:Xns9584247208CC4ukcoREMOVEfreenetrtw@130.133.1.4...
> "Chris Theis" wrote in news:cko3t1$dla$1@sunnews.cern.ch in
> comp.std.c++:
>
> > Hi all,
> >
> > I ve been some looking around lately regarding NRVO. Up to now a
> > number of compilers (gcc 3.3, zortech, cfront, Intel 6., MSVC 7.1
> > etc.) do implement this on the optimization level. However, I wonder
> > whether there are any plans to incorporate this into the requirements
> > of the standard. Does anyone know a little more if there are such
> > plans and how far this has gone up to now?
> >
>
> Example:
>
> struct A { int a; };
>
> A f()
> {
> A nrv;
> return nrv;
> }
>
> Given that on many systems int's are typicaly returned in registers
> a Named Return Value *Requirment* would actually be a slowdown for
> the above code on many platform's as the option to return via a
> rvalue/temporary (in a register) would be removed.
>
> I may be wrong but I suspect this is the reason RVO/NRVO are
> *Optimizations* in the first place.
>
> Rob.
I agree with you on that issue, but the interesting thing is that most
compilers perform NRVO "optimization" even without having optimization
explicitly turned on. But to what extent and whether situations like the one
you gave above are handled well, is beyond my knowledge without checking the
actual assembler code.
Cheers
Chris
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
Author: rtw@freenet.co.uk (Rob Williscroft)
Date: Sun, 17 Oct 2004 20:43:50 GMT Raw View
"Chris Theis" wrote in news:ckqn2s$hlp$1@sunnews.cern.ch in
comp.std.c++:
> I agree with you on that issue, but the interesting thing is that most
> compilers perform NRVO "optimization" even without having optimization
> explicitly turned on.
Yep, but the standard doesn't mention the term's RVO and NRVO, they are
just thing's somebody made up to describe what the standard allows, and
that they're optional.
Named Return Value Optional-behaviour maybe :).
> But to what extent and whether situations like
> the one you gave above are handled well, is beyond my knowledge
> without checking the actual assembler code.
>
I don't know either, the last time I took an interest in such things
it was with a pre-standard compiler, but at that time Borland C++
had some rules about which UDT's it would return in registers,
1 byte, 2 byte and 4 byte structs only IIRC.
Rob.
--
http://www.victim-prime.dsl.pipex.com/
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
Author: Chris.Theis@nospam.cern.ch ("Chris Theis")
Date: Fri, 15 Oct 2004 21:19:18 GMT Raw View
Hi all,
I ve been some looking around lately regarding NRVO. Up to now a number of
compilers (gcc 3.3, zortech, cfront, Intel 6., MSVC 7.1 etc.) do implement
this on the optimization level. However, I wonder whether there are any
plans to incorporate this into the requirements of the standard. Does anyone
know a little more if there are such plans and how far this has gone up to
now?
Cheers
Chris
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
Author: rtw@freenet.co.uk (Rob Williscroft)
Date: Sat, 16 Oct 2004 03:26:35 GMT Raw View
"Chris Theis" wrote in news:cko3t1$dla$1@sunnews.cern.ch in
comp.std.c++:
> Hi all,
>
> I ve been some looking around lately regarding NRVO. Up to now a
> number of compilers (gcc 3.3, zortech, cfront, Intel 6., MSVC 7.1
> etc.) do implement this on the optimization level. However, I wonder
> whether there are any plans to incorporate this into the requirements
> of the standard. Does anyone know a little more if there are such
> plans and how far this has gone up to now?
>
Example:
struct A { int a; };
A f()
{
A nrv;
return nrv;
}
Given that on many systems int's are typicaly returned in registers
a Named Return Value *Requirment* would actually be a slowdown for
the above code on many platform's as the option to return via a
rvalue/temporary (in a register) would be removed.
I may be wrong but I suspect this is the reason RVO/NRVO are
*Optimizations* in the first place.
Rob.
--
http://www.victim-prime.dsl.pipex.com/
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]