public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c++/9460: parse error on template member function
@ 2003-01-27 19:26 oliver.schoenborn
0 siblings, 0 replies; 7+ messages in thread
From: oliver.schoenborn @ 2003-01-27 19:26 UTC (permalink / raw)
To: gcc-gnats
>Number: 9460
>Category: c++
>Synopsis: parse error on template member function
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: rejects-legal
>Submitter-Id: net
>Arrival-Date: Mon Jan 27 19:26:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: Oliver Schoenborn
>Release: 3.2.2 on cygwin, 3.2 linux, 3.0.4 SGI
>Organization:
>Environment:
Cygwin (latest), linux redhat 7.3, SGI Irix 6.5.13
>Description:
struct Test
{
template <typename T>
void test(T*) {}
};
template <typename ObjType>
struct Foo
{
Test _state;
int _i;
void reset()
{
_state.test(&_i); // ok
_state.test<ObjType>(&_i); // parse error here if...
}
// ... and only if following is not
// same name as Test::test!!!!
template <typename TT>
void test2() {}
};
int main()
{
Foo<int> test;
test.reset();
}
>How-To-Repeat:
Just try to compile the file with "g++ -c file.cc"
>Fix:
none except hack: add extra parameters to function so it can deduce template parameter
Colleague has reported that these may work too (not tested rigorously):
_state.template test<ObjType>(&_i); //avoids the error
_state.Test::test<ObjType>(&_i); //avoids the error
>Release-Note:
>Audit-Trail:
>Unformatted:
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: c++/9460: parse error on template member function
@ 2003-01-29 15:46 Wolfgang Bangerth
0 siblings, 0 replies; 7+ messages in thread
From: Wolfgang Bangerth @ 2003-01-29 15:46 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR c++/9460; it has been noted by GNATS.
From: Wolfgang Bangerth <bangerth@ticam.utexas.edu>
To: Giovanni Bajo <giovannibajo@libero.it>
Cc: Oliver Schoenborn <oliver.schoenborn@utoronto.ca>, <gcc-gnats@gcc.gnu.org>,
<gcc-bugs@gcc.gnu.org>
Subject: Re: c++/9460: parse error on template member function
Date: Wed, 29 Jan 2003 09:35:45 -0600 (CST)
> Sorry for the confusion. The problem is, the compiler still has symmetric
> behaviour:
>
> Foo().F1<A>() compiles with no errors, while it needs the template keyword.
> (accept-illegal)
Which compiler did you check this with? It is well known that before the
new parser was merged into the 3.4 tree, things were wrong. The hope is
that with the new parser we are moving closer to standards conformance.
W.
-------------------------------------------------------------------------
Wolfgang Bangerth email: bangerth@ticam.utexas.edu
www: http://www.ticam.utexas.edu/~bangerth/
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: c++/9460: parse error on template member function
@ 2003-01-29 9:16 Giovanni Bajo
0 siblings, 0 replies; 7+ messages in thread
From: Giovanni Bajo @ 2003-01-29 9:16 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR c++/9460; it has been noted by GNATS.
From: "Giovanni Bajo" <giovannibajo@libero.it>
To: "Wolfgang Bangerth" <bangerth@ticam.utexas.edu>,
"Oliver Schoenborn" <oliver.schoenborn@utoronto.ca>
Cc: <gcc-gnats@gcc.gnu.org>,
<gcc-bugs@gcc.gnu.org>
Subject: Re: c++/9460: parse error on template member function
Date: Wed, 29 Jan 2003 10:09:39 +0100
----- Original Message -----
From: "Wolfgang Bangerth" <bangerth@ticam.utexas.edu>
To: "Oliver Schoenborn" <oliver.schoenborn@utoronto.ca>
Cc: <gcc-gnats@gcc.gnu.org>
Sent: Tuesday, January 28, 2003 10:14 PM
Subject: Re: c++/9460: parse error on template member function
> It would be different if you would call
> Foo().F1<A> ();
> in which case you would have to use
> Foo().template F1<A> ();
Sorry for the confusion. The problem is, the compiler still has symmetric
behaviour:
Foo().F1<A>() compiles with no errors, while it needs the template keyword.
(accept-illegal)
In my first code snippet, if you remove Bar::F1, the code fails to compile.
(reject-legal).
Giovanni Bajo
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: c++/9460: parse error on template member function
@ 2003-01-28 21:16 Wolfgang Bangerth
0 siblings, 0 replies; 7+ messages in thread
From: Wolfgang Bangerth @ 2003-01-28 21:16 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR c++/9460; it has been noted by GNATS.
From: Wolfgang Bangerth <bangerth@ticam.utexas.edu>
To: Oliver Schoenborn <oliver.schoenborn@utoronto.ca>
Cc: gcc-gnats@gcc.gnu.org, <farfetchd@libero.it>
Subject: Re: c++/9460: parse error on template member function
Date: Tue, 28 Jan 2003 15:14:57 -0600 (CST)
On Tue, 28 Jan 2003, Oliver Schoenborn wrote:
> OK for the section, BUT there is still a bug, just not the right category
> (like another developer said): when the member function name is changed from
> test2 to test, the parse error disappears a few lines above disappears. This
> has to be re-opened and re-categorized.
No, Giovanni is wrong: both examples he shows are perfectly legal: in the
first one, Foo::F1 is called as can easily be seen in the assembler
output. The fact the Bar::F1 exists has no influence whatsoever.
In the second, the same obviously holds.
In both cases, you don't need the "template" keyword for disambiguation,
since neither the expression before the "." is template dependent (it is
just an object of non-templated type "Foo"), nor the one after the dot,
which _is_ templates by the template type is known at the time of parsing,
being a constant "int". It would be different if you would call
Foo().F1<A> ();
in which case you would have to use
Foo().template F1<A> ();
Unfortunately, this ICEs with the present mainline compile (I just filed a
report for this).
W.
-------------------------------------------------------------------------
Wolfgang Bangerth email: bangerth@ticam.utexas.edu
www: http://www.ticam.utexas.edu/~bangerth/
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: c++/9460: parse error on template member function
@ 2003-01-28 21:16 Wolfgang Bangerth
0 siblings, 0 replies; 7+ messages in thread
From: Wolfgang Bangerth @ 2003-01-28 21:16 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR c++/9460; it has been noted by GNATS.
From: Wolfgang Bangerth <bangerth@ticam.utexas.edu>
To: gcc-gnats@gcc.gnu.org
Cc:
Subject: Re: c++/9460: parse error on template member function
Date: Tue, 28 Jan 2003 15:08:44 -0600 (CST)
---------- Forwarded message ----------
Date: Tue, 28 Jan 2003 15:12:35 -0500
From: Oliver Schoenborn <oliver.schoenborn@utoronto.ca>
To: Wolfgang Bangerth <bangerth@ticam.utexas.edu>
Cc: bangerth@dealii.org
Subject: Re: c++/9460: parse error on template member function
OK for the section, BUT there is still a bug, just not the right category
(like another developer said): when the member function name is changed from
test2 to test, the parse error disappears a few lines above disappears. This
has to be re-opened and re-categorized.
Oliver
----- Original Message -----
From: "Wolfgang Bangerth" <bangerth@ticam.utexas.edu>
To: "Oliver Schoenborn" <oliver.schoenborn@utoronto.ca>
Cc: <bangerth@dealii.org>
Sent: Monday, January 27, 2003 7:08 PM
Subject: Re: c++/9460: parse error on template member function
>
> > Sorry I have a hard time believing that the language requires full
> > qualification or the template prefix. Can you cite the section of the
> > Standards that you are using as justification, so I can verify this?
>
> 14.2.4 ist wohl die richtige Stelle.
>
> Gruss
> W.
>
> -------------------------------------------------------------------------
> Wolfgang Bangerth email: bangerth@ticam.utexas.edu
> www: http://www.ticam.utexas.edu/~bangerth/
>
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: c++/9460: parse error on template member function
@ 2003-01-28 2:36 Farfetch'd
0 siblings, 0 replies; 7+ messages in thread
From: Farfetch'd @ 2003-01-28 2:36 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR c++/9460; it has been noted by GNATS.
From: "Farfetch'd" <farfetchd@libero.it>
To: <gcc-gnats@gcc.gnu.org>,
<gcc-bugs@gcc.gnu.org>,
<oliver.schoenborn@utoronto.ca>,
<nobody@gcc.gnu.org>,
<gcc-prs@gcc.gnu.org>
Cc:
Subject: Re: c++/9460: parse error on template member function
Date: Tue, 28 Jan 2003 03:34:27 +0100
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&p
r=9460
I am not absolutely sure there is no bug here. For example, look at the
following snippet:
------------
struct Foo
{
template <typename T>
void F1(void) {}
};
template <typename A>
struct Bar
{
void F2(void)
{
Foo f;
f.F1<int>();
}
template <typename T>
void F1(void) {}
};
template Bar<int>;
------------
The previous snippet is accepted by G++ but it shouldn't since it's not
legal. The compiler is fooled by Bar::F1<> having the same name of
Foo::F1<>. Also the following code is accepted as well and should not:
------------
struct Foo
{
template <typename T>
void F1(void) {}
};
template <typename A>
struct Bar
{
void F2(void)
{
Foo().F1<int>();
}
};
template Bar<int>;
------------
since it's still missing the template keyword in the member template call.
So it's not a case of reject-legal, but of accept-illegal.
Giovanni Bajo
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: c++/9460: parse error on template member function
@ 2003-01-27 19:55 bangerth
0 siblings, 0 replies; 7+ messages in thread
From: bangerth @ 2003-01-27 19:55 UTC (permalink / raw)
To: gcc-bugs, gcc-prs, nobody, oliver.schoenborn
Synopsis: parse error on template member function
State-Changed-From-To: open->closed
State-Changed-By: bangerth
State-Changed-When: Mon Jan 27 19:55:21 2003
State-Changed-Why:
Not a bug. One of the "work-arounds" you cite is mandated
by the language.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9460
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2003-01-29 15:46 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-27 19:26 c++/9460: parse error on template member function oliver.schoenborn
2003-01-27 19:55 bangerth
2003-01-28 2:36 Farfetch'd
2003-01-28 21:16 Wolfgang Bangerth
2003-01-28 21:16 Wolfgang Bangerth
2003-01-29 9:16 Giovanni Bajo
2003-01-29 15:46 Wolfgang Bangerth
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).