This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


------- 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]