This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
weird call to copy ctor
- To: egcs-bugs at cygnus dot com
- Subject: weird call to copy ctor
- From: Christian Millour <chris161 at club-internet dot fr>
- Date: Fri, 26 Jun 1998 09:25:53 +0200
// Hi. The following problem was raised recently on the french c++
// newsgroup. Sorry if it has been reported already.
// I have used egcs version 1.0.3
// In the following snippet, the call to f (really f<int>(A<int>) )
// triggers a call to B<int>::B(B<int> const &), which is wrong.
// Only the A<int> part should be copied.
#include <cassert>
template <class T> struct A {};
template <class T>
struct B : public A<T> {
B() {}
B(B const &) { assert(0); }
};
template <class T> void f(A<T>) {}
int main()
{
B<int> b;
f(b); // B<int>::B(B<int> const &) invoked here !?!?
}