public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/4862: Parse error with templated member function
@ 2001-11-05  6:26 lerdsuwa
  0 siblings, 0 replies; 3+ messages in thread
From: lerdsuwa @ 2001-11-05  6:26 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/4862; it has been noted by GNATS.

From: lerdsuwa@gcc.gnu.org
To: csk@cs.washington.edu, gcc-bugs@gcc.gnu.org, gcc-gnats@gcc.gnu.org,
  gcc-prs@gcc.gnu.org, nobody@gcc.gnu.org
Cc:  
Subject: Re: c++/4862: Parse error with templated member function
Date: 16 Nov 2001 17:29:16 -0000

 Synopsis: Parse error with templated member function
 
 State-Changed-From-To: open->analyzed
 State-Changed-By: lerdsuwa
 State-Changed-When: Fri Nov 16 09:29:15 2001
 State-Changed-Why:
     Confirmed.  A known work around is to add 'template' such as
       a.template func<T>();
     inside doit().
 
 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&pr=4862&database=gcc


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

* Re: c++/4862: Parse error with templated member function
@ 2001-11-05  6:26 lerdsuwa
  0 siblings, 0 replies; 3+ messages in thread
From: lerdsuwa @ 2001-11-05  6:26 UTC (permalink / raw)
  To: csk, gcc-bugs, gcc-gnats, gcc-prs, nobody

Synopsis: Parse error with templated member function

State-Changed-From-To: open->analyzed
State-Changed-By: lerdsuwa
State-Changed-When: Fri Nov 16 09:29:15 2001
State-Changed-Why:
    Confirmed.  A known work around is to add 'template' such as
      a.template func<T>();
    inside doit().

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


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

* c++/4862: Parse error with templated member function
@ 2001-11-01 15:46 csk
  0 siblings, 0 replies; 3+ messages in thread
From: csk @ 2001-11-01 15:46 UTC (permalink / raw)
  To: gcc-gnats


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


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

end of thread, other threads:[~2001-11-16 17:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-11-05  6:26 c++/4862: Parse error with templated member function lerdsuwa
  -- strict thread matches above, loose matches on Subject: below --
2001-11-05  6:26 lerdsuwa
2001-11-01 15:46 csk

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