Created on 2001-11-02.00:00:00 last changed 197 months ago
[Voted into WP at April 2005 meeting.]
Proposed resolution (October, 2004):
In 6.7.7 [class.temporary] paragraph 2, change the last sentence as indicated:
On the other hand, the expression a=f(a) requires a temporary foreither the argument a or the result of f(a) to avoid undesired aliasing of athe result of f(a), which is then assigned to a.
Section 6.7.7 [class.temporary] paragraph 2, abridged:
X f(X); void g() { X a; a = f(a); }a=f(a) requires a temporary for either the argument a or the result of f(a) to avoid undesired aliasing of a.
The note seems to imply that an implementation is allowed to omit copying "a" to f's formal argument, or to omit using a temporary for the return value of f. I don't find that license in normative text.
Function f returns an X by value, and in the expression the value is assigned (not copy-constructed) to "a". I don't see how that temporary can be omitted. (See also 11.4.5.3 [class.copy.ctor] p 15)
Since "a" is an lvalue and not a temporary, I don't see how copying "a" to f's formal parameter can be avoided.
Am I missing something, or is 6.7.7 [class.temporary] p 2 misleading?
History | |||
---|---|---|---|
Date | User | Action | Args |
2008-10-05 00:00:00 | admin | set | status: wp -> cd1 |
2005-10-22 00:00:00 | admin | set | status: dr -> wp |
2005-05-01 00:00:00 | admin | set | messages: + msg1194 |
2005-05-01 00:00:00 | admin | set | status: ready -> dr |
2004-11-07 00:00:00 | admin | set | messages: + msg1048 |
2004-11-07 00:00:00 | admin | set | status: open -> ready |
2001-11-02 00:00:00 | admin | create |