This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Trouble with copy-ctor
- From: Reichelt <reichelt at igpm dot rwth-aachen dot de>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 4 Jan 2002 17:55:56 +0100
- Subject: Trouble with copy-ctor
Hi,
the following example looks like legal code to me:
struct A
{
A(A&);
A(int);
};
A a = 0;
But compiling it with "g++ -c" I get the following error:
bug.cpp: In function `void __static_initialization_and_destruction_0(int, int)':
bug.cpp:8: no matching function for call to `A::A(A)'
bug.cpp:5: candidates are: A::A(int)
bug.cpp:3: A::A(A&)
bug.cpp:8: initializing temporary from result of `A::A(int)'
IMHO there should be a call to "A(int)" to convert "0" into something of
type "A". Then a copy-ctor should be called to initialize "a" with this
value. The question is: Why is "A::A(A&)" non-matching?
The temporary from the call "A::A(int)" isn't "const", is it?
Then one should be able to call the copy-ctor "A::A(A&)".
Am I wrong, or is this a bug in gcc?
I get error messages with gcc 2.95.2, 3.0.x, and 3.1 20011231.
If g++ is at fault, I can file a PR into GNATS.
Greetings,
Volker Reichelt