This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/15704] Copy constructor is not called
- From: "pinskia at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 6 Jun 2004 01:05:13 -0000
- Subject: [Bug c++/15704] Copy constructor is not called
- References: <20040528101645.15704.justin@cs.utah.edu>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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