From: Doug Gregor (dgregor_at_[hidden])
Date: 2004-11-18 10:00:50
On Nov 17, 2004, at 9:55 PM, David Abrahams wrote:
> "Thorsten Ottosen" <nesotto_at_[hidden]> writes:
>> Here's my take on it: a compiler is allowed to a remove any copy
>> operations as
>> long as the programs observed behavior is the
>> same. AFAICT, copying (or assigning) a vector<int> (compared to not
>> doing it)
>> will never change the observed behavior.
> You're kidding, right? I doubt very much that the compiler can
> legitimately decide that side effects on the memory subsystem due to
> allocation are not observable.
Since I've been researching in this area for several years...
Dave is correct: no compiler out there is going to optimize this,
because the side effects are killer. It is possible to analyze that
behavior and perform the optimization Thorsten is describing, but
(1) There are better ways than looking at it from the memory
subsystem/pointer magic angle
(2) This is very much an open research area; don't expect this from a
research compiler for at least 2 years.
(3) This is very much an open research area; don't expect this from a
commercial compiler for at least 10 years.
Copy elision and the RVO are all we have. We can't rely on anything
more than that.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk