public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c++/9050: Can't explicitly instantiate C++ constructor templates
@ 2002-12-23 19:06 martin
  0 siblings, 0 replies; 2+ messages in thread
From: martin @ 2002-12-23 19:06 UTC (permalink / raw)
  To: gcc-gnats


>Number:         9050
>Category:       c++
>Synopsis:       Can't explicitly instantiate C++ constructor templates
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Mon Dec 23 19:06:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Martin Buchholz
>Release:        g++ 3.2.1
>Organization:
>Environment:
Linux x86
>Description:
C++ function templates can be explicitly instantiated.
Constructors can be function templates.
So the following should compile 
(and indeed does with icc and Comeau C++)

struct Y
{
  template <typename T> Y (T);
  template <typename T> void foo (T);
};

template <> void Y::foo      (bool) { }
template <> void Y::foo<int> (int)  { }

template <>      Y::Y        (bool) { }
template <>      Y::Y<int>   (int)  { }


Explicit instantiation of Y::foo, 
but not Y::Y, is permitted.

g++ gives these errors:

(not only is g++ wrong to give an error,
but the error message below contains the nonsensical
"no member function `._0' declared")

constructor-explicit-instantiation-bug.cc:11: `Y' is not a template
constructor-explicit-instantiation-bug.cc:11: ISO C++ forbids declaration of `
   type name' with no type
constructor-explicit-instantiation-bug.cc:11: abstract declarator `int 
   (Y::)(int)' used as declaration
constructor-explicit-instantiation-bug.cc:11: no member function `._0' declared 
   in `Y'
constructor-explicit-instantiation-bug.cc:11: syntax error before `{' token
>How-To-Repeat:
Compile the provided fragment with "g++ -c"
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: c++/9050: Can't explicitly instantiate C++ constructor templates
@ 2002-12-25  0:00 lerdsuwa
  0 siblings, 0 replies; 2+ messages in thread
From: lerdsuwa @ 2002-12-25  0:00 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, martin, nobody

Synopsis: Can't explicitly instantiate C++ constructor templates

State-Changed-From-To: open->analyzed
State-Changed-By: lerdsuwa
State-Changed-When: Wed Dec 25 00:00:37 2002
State-Changed-Why:
    Confirmed.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9050


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-12-25  8:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-23 19:06 c++/9050: Can't explicitly instantiate C++ constructor templates martin
2002-12-25  0:00 lerdsuwa

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).