public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: martin@xemacs.org
To: gcc-gnats@gcc.gnu.org
Subject: c++/9050: Can't explicitly instantiate C++ constructor templates
Date: Mon, 23 Dec 2002 19:06:00 -0000	[thread overview]
Message-ID: <20021224030041.10995.qmail@sources.redhat.com> (raw)


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


             reply	other threads:[~2002-12-24  3:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-23 19:06 martin [this message]
2002-12-25  0:00 lerdsuwa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20021224030041.10995.qmail@sources.redhat.com \
    --to=martin@xemacs.org \
    --cc=gcc-gnats@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).