public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: csk@cs.washington.edu
To: gcc-gnats@gcc.gnu.org
Subject: c++/4862: Parse error with templated member function
Date: Thu, 01 Nov 2001 15:46:00 -0000	[thread overview]
Message-ID: <20011112220644.20862.qmail@sourceware.cygnus.com> (raw)


>Number:         4862
>Category:       c++
>Synopsis:       Parse error with templated member function
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Mon Nov 12 14:16:01 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     csk@cs.washington.edu
>Release:        3.0.2
>Organization:
>Environment:
Redhat 7.2, i686
>Description:
The following code yields a parse error on the line "a.func<T>();":

----------------------------
#include <iostream>

class A
{
public:
    template<typename T>
    void func()
    {
        std::cout << T() << std::endl;
    }
};

template<typename T>
void doit()
{
    A a;
    a.func<T>();
}

int main( int argc, char ** argv )
{
    if( argc > 0 ) {
        doit<int>();
    } else {
        doit<float>();
    }
}
--------------------------------

Surely the definition of "doit" should be legal.  On the other hand, if you erase the "doit" function from the code and replace "main" with this:

----------------------------------
int main( int argc, char ** argv )
{
    if( argc > 0 ) {
        A a;
        a.func<int>();
    } else {
        A a;
        a.func<float>();
    }
}
----------------------------------------------

Everything compiles okay.  This suggests to me that the first version of the code should be legal.
>How-To-Repeat:

>Fix:

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


             reply	other threads:[~2001-11-12 22:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-11-01 15:46 csk [this message]
2001-11-05  6:26 lerdsuwa
2001-11-05  6:26 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=20011112220644.20862.qmail@sourceware.cygnus.com \
    --to=csk@cs.washington.edu \
    --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).