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]

weird call to copy ctor


// 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 !?!?
}



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