[Bug c++/15704] Copy constructor is not called

pinskia at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Sun Jun 6 01:05:00 GMT 2004


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-06-06 01:05 -------
Not a bug, read 12.2P2
>From 12.2P2:
[Example: 
class X { 
//... 
public:
 //...
X(int);
 X(const X&); 
~X(); 
};
 X f(X); 
void g() { 
X a(1); 
X b = f(X(2)); 
a = f(a); 
}
 Here, an implementation might use a temporary in which to construct X(2) before passing it to f() using 
XÂ’s copy-constructor; alternatively, X(2) might be constructed in the space used to hold the argument. 
Also, a temporary might be used to hold the result of f(X(2)) before copying it to b using XÂ’s copy 
constructor; alternatively, f()Â’s result might be constructed in b. On the other hand, the expression 
a=f(a) requires a temporary for either the argumentaor the result of f(a) to avoid undesired aliasing of 
a. ] 

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15704



More information about the Gcc-bugs mailing list