This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: c++/9987: Failure to call a copy constructor with complex templated member functions.
- From: bangerth at dealii dot org
- To: a dot shipman at bom dot gov dot au, gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, nobody at gcc dot gnu dot org
- Date: 7 Mar 2003 14:55:56 -0000
- Subject: Re: c++/9987: Failure to call a copy constructor with complex templated member functions.
- Reply-to: bangerth at dealii dot org, a dot shipman at bom dot gov dot au, gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, nobody at gcc dot gnu dot org, gcc-gnats at gcc dot gnu dot org
Synopsis: Failure to call a copy constructor with complex templated member functions.
State-Changed-From-To: open->closed
State-Changed-By: bangerth
State-Changed-When: Fri Mar 7 14:55:56 2003
State-Changed-Why:
Not a bug. If you have
template <class T> class X {
template <class U> X (const X<U> &);
}
X<int> x_int1;
X<int> x_int2(x_int1);
X<char> x_char(x_int1);
then the templated copy constructor is called in the
initialization of x_char, but _not_ in that of x_int2. For
the latter, the compiler synthesizes the byte-copy default
copy constructor. If you want to have a user defined
copy constructor for the case T==U, then you have to declare
and implement it. Doing so in your program makes the SegFault
go away (just checked that).
Regards
Wolfgang
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9987