public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c++/3629: nested template constructor doesn't get used as copy constructor
@ 2001-07-09 14:06 Paul J. Lucas
0 siblings, 0 replies; 3+ messages in thread
From: Paul J. Lucas @ 2001-07-09 14:06 UTC (permalink / raw)
To: gcc-gnats
Note: There was a bad value `wrong' for the field `>Class:'.
It was set to the default value of `sw-bug'.
>Number: 3629
>Category: c++
>Synopsis: nested template constructor doesn't get used as copy constructor
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Jul 09 14:06:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator: Paul J. Lucas
>Release: 3.0
>Organization:
>Environment:
System: Linux powerbook 2.2.17 #2 Wed Nov 22 16:34:45 PST 2000 ppc unknown
Architecture: ppc
host: powerpc-unknown-linux-gnu
build: powerpc-unknown-linux-gnu
target: powerpc-unknown-linux-gnu
configured with: ./configure --prefix=/usr/local/packages/gcc-3.0 --enable-languages=c++
>Description:
A used-defined template copy constructor inside a template class
doesn't get used to generate a copy constructor when the types equal.
>How-To-Repeat:
#include <iostream>
template< class T > struct A {
A() { }
template< class U > A( A<U> const& ) { std::cerr << "Here!\n"; }
};
main() {
A<int> a;
/*
** The line below should cause "Here!" to be printed because, when the
** type T = type U, it matches the signature of a copy constructor and
** the one defined above should be called. However, the compiler
** still generates a default copy constructor and doesn't use the above
** one.
*/
A<int> b( a );
}
>Fix:
A non-template copy constructor can be written explicitly, e.g.:
A( A const& );
but the user shouldn't have to.
>Release-Note:
>Audit-Trail:
>Unformatted:
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: c++/3629: nested template constructor doesn't get used as copy constructor
@ 2001-07-09 14:16 Gabriel Dos Reis
0 siblings, 0 replies; 3+ messages in thread
From: Gabriel Dos Reis @ 2001-07-09 14:16 UTC (permalink / raw)
To: gdr; +Cc: gcc-prs
The following reply was made to PR c++/3629; it has been noted by GNATS.
From: Gabriel Dos Reis <Gabriel.Dos-Reis@cmla.ens-cachan.fr>
To: "Paul J. Lucas" <pauljlucas@mac.com>
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: c++/3629: nested template constructor doesn't get used as copy constructor
Date: 09 Jul 2001 23:13:30 +0200
"Paul J. Lucas" <pauljlucas@mac.com> writes:
| A used-defined template copy constructor inside a template class
| doesn't get used to generate a copy constructor when the types equal.
That is a C++ conformant behaviour: A copy constructor cannot be
generated from a template constructor.
So Not a Bug.
-- Gaby
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: c++/3629: nested template constructor doesn't get used as copy constructor
@ 2001-07-09 14:14 gdr
0 siblings, 0 replies; 3+ messages in thread
From: gdr @ 2001-07-09 14:14 UTC (permalink / raw)
To: gcc-bugs, gcc-prs, gdr, nobody, pauljlucas
Synopsis: nested template constructor doesn't get used as copy constructor
Responsible-Changed-From-To: unassigned->gdr
Responsible-Changed-By: gdr
Responsible-Changed-When: Mon Jul 9 14:14:47 2001
Responsible-Changed-Why:
Analyzed.
State-Changed-From-To: open->closed
State-Changed-By: gdr
State-Changed-When: Mon Jul 9 14:14:47 2001
State-Changed-Why:
Not a bug.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=3629&database=gcc
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2001-07-09 14:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-07-09 14:06 c++/3629: nested template constructor doesn't get used as copy constructor Paul J. Lucas
2001-07-09 14:14 gdr
2001-07-09 14:16 Gabriel Dos Reis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).