Bug related to template constructor and default copy constructor

Budulea Eduard eduard.budulea@axigen.com
Fri Nov 23 16:27:00 GMT 2007


Hi is I have a This snip that will compile but print only one bingo instead of two.
The gcc is version 4.1.2
==========
#include<iostream>
using namespace std;

class A {
public:
     A () {}
     template<class T>
         A(T const &orig) {
             cout<<"bingo!"<<endl;
         }
};

class B {
};

int main(int argc, char *argv[]) {
     A a;
     A b(a);
     B c;
     A d(c);
     return 0;
}
===========

The problem is that a default copy constructor is isued instead of using the specialization of the template function.

-- 
__________________________________________________
Eduard Timotei BUDULEA                       / \
Software Developer - GECAD Technologies      \ /
mailto: eduard.budulea@axigen.com             X
        ASCII Ribbon against HTML-mail       / \
__________________________________________________



More information about the Gcc-bugs mailing list