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]
Other format: [Raw text]

c++/9050: Can't explicitly instantiate C++ constructor templates


>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:


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