public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/17000] parse error calling member template function of non-lvalue from within template class member
[not found] <bug-17000-4@http.gcc.gnu.org/bugzilla/>
@ 2021-07-24 1:43 ` pinskia at gcc dot gnu.org
2024-02-16 17:56 ` mpolacek at gcc dot gnu.org
1 sibling, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-24 1:43 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=17000
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to fail| |
--- Comment #11 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
clang also rejects this code for the same reason as GCC.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/17000] parse error calling member template function of non-lvalue from within template class member
[not found] <bug-17000-4@http.gcc.gnu.org/bugzilla/>
2021-07-24 1:43 ` [Bug c++/17000] parse error calling member template function of non-lvalue from within template class member pinskia at gcc dot gnu.org
@ 2024-02-16 17:56 ` mpolacek at gcc dot gnu.org
1 sibling, 0 replies; 12+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2024-02-16 17:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=17000
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|NEW |RESOLVED
CC| |mpolacek at gcc dot gnu.org
--- Comment #12 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
We say
17000.C: In member function ‘void b<T>::func()’:
17000.C:10:17: warning: expected ‘template’ keyword before dependent template
name [-Wmissing-template-keyword]
10 | get_a().func2 <int>();
| ^~~~~
| template
and clang++ says
17000.C:10:17: error: use 'template' keyword to treat 'func2' as a dependent
template name
10 | get_a().func2 <int>();
| ^
| template
I think we can close this.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/17000] parse error calling member template function of non-lvalue from within template class member
[not found] <bug-17000-3238@http.gcc.gnu.org/bugzilla/>
` (2 preceding siblings ...)
2007-03-18 11:02 ` matt at galloway dot me dot uk
@ 2007-04-20 17:51 ` ddneilson at gmail dot com
3 siblings, 0 replies; 12+ messages in thread
From: ddneilson at gmail dot com @ 2007-04-20 17:51 UTC (permalink / raw)
To: gcc-bugs
------- Comment #10 from ddneilson at gmail dot com 2007-04-20 18:51 -------
(In reply to comment #9)
> (In reply to comment #8)
> > The work around is doing:
> > get_a().template func2 <int>();
> >
> >
> > Which tells the compiler for sure func2 is a template.
> >
>
> Thanks, yeh I figured that out just now. Should it happen like this though?
> Surely the compiler should be able to work out it's a template and therefore
> not need the qualification?
>
I was just about to report a similar bug, but it was also "fixed" by adding a
"template" qualifier to the function call.
However, when studying the bug I ran my test case through the xlC compiler. It
compiles "get_a().func2<int>();" just fine; it doesn't need "get_a().template
func2<int>();" syntax.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17000
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/17000] parse error calling member template function of non-lvalue from within template class member
[not found] <bug-17000-3238@http.gcc.gnu.org/bugzilla/>
2007-03-18 1:06 ` matt at galloway dot me dot uk
2007-03-18 6:12 ` pinskia at gcc dot gnu dot org
@ 2007-03-18 11:02 ` matt at galloway dot me dot uk
2007-04-20 17:51 ` ddneilson at gmail dot com
3 siblings, 0 replies; 12+ messages in thread
From: matt at galloway dot me dot uk @ 2007-03-18 11:02 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from matt at galloway dot me dot uk 2007-03-18 11:01 -------
(In reply to comment #8)
> The work around is doing:
> get_a().template func2 <int>();
>
>
> Which tells the compiler for sure func2 is a template.
>
Thanks, yeh I figured that out just now. Should it happen like this though?
Surely the compiler should be able to work out it's a template and therefore
not need the qualification?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17000
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/17000] parse error calling member template function of non-lvalue from within template class member
[not found] <bug-17000-3238@http.gcc.gnu.org/bugzilla/>
2007-03-18 1:06 ` matt at galloway dot me dot uk
@ 2007-03-18 6:12 ` pinskia at gcc dot gnu dot org
2007-03-18 11:02 ` matt at galloway dot me dot uk
2007-04-20 17:51 ` ddneilson at gmail dot com
3 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-03-18 6:12 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from pinskia at gcc dot gnu dot org 2007-03-18 06:12 -------
The work around is doing:
get_a().template func2 <int>();
Which tells the compiler for sure func2 is a template.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17000
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/17000] parse error calling member template function of non-lvalue from within template class member
[not found] <bug-17000-3238@http.gcc.gnu.org/bugzilla/>
@ 2007-03-18 1:06 ` matt at galloway dot me dot uk
2007-03-18 6:12 ` pinskia at gcc dot gnu dot org
` (2 subsequent siblings)
3 siblings, 0 replies; 12+ messages in thread
From: matt at galloway dot me dot uk @ 2007-03-18 1:06 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from matt at galloway dot me dot uk 2007-03-18 01:06 -------
Same problem for me with gcc-4.0.1. Is this going to get fixed or is it correct
behaviour and the code needs some sort of codeword to tell the compiler that
func2 is a template?
--
matt at galloway dot me dot uk changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |matt at galloway dot me dot
| |uk
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17000
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/17000] parse error calling member template function of non-lvalue from within template class member
2004-08-12 11:08 [Bug c++/17000] New: " stefaandr at hotmail dot com
` (4 preceding siblings ...)
2004-08-12 14:58 ` pinskia at gcc dot gnu dot org
@ 2004-08-12 15:15 ` bangerth at dealii dot org
5 siblings, 0 replies; 12+ messages in thread
From: bangerth at dealii dot org @ 2004-08-12 15:15 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2004-08-12 15:15 -------
Again, the call to get_a() is of course dependent. However, the
_return type_ is not.
W.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17000
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/17000] parse error calling member template function of non-lvalue from within template class member
2004-08-12 11:08 [Bug c++/17000] New: " stefaandr at hotmail dot com
` (3 preceding siblings ...)
2004-08-12 14:34 ` giovannibajo at libero dot it
@ 2004-08-12 14:58 ` pinskia at gcc dot gnu dot org
2004-08-12 15:15 ` bangerth at dealii dot org
5 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-08-12 14:58 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-08-12 14:58 -------
Confirmed, from someone who has not looked into the source, it seems like get get_a is being marked
as dependent for some reason when it should not be. But it seems werid that ICC 6.0 also reject this
code even in struct mode.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Keywords| |rejects-valid
Known to fail| |2.95.3 3.3.3 3.0.4 3.4.0
| |3.5.0
Last reconfirmed|0000-00-00 00:00:00 |2004-08-12 14:58:45
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17000
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/17000] parse error calling member template function of non-lvalue from within template class member
2004-08-12 11:08 [Bug c++/17000] New: " stefaandr at hotmail dot com
` (2 preceding siblings ...)
2004-08-12 14:20 ` bangerth at dealii dot org
@ 2004-08-12 14:34 ` giovannibajo at libero dot it
2004-08-12 14:58 ` pinskia at gcc dot gnu dot org
2004-08-12 15:15 ` bangerth at dealii dot org
5 siblings, 0 replies; 12+ messages in thread
From: giovannibajo at libero dot it @ 2004-08-12 14:34 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From giovannibajo at libero dot it 2004-08-12 14:34 -------
OK I got confused and thought there was a way to change the return type on
specialization, but there obviously can't be (at least without specialize the
entire class). Then, it makes sense for the code to be valid as-is.
Both ICC and MSVC have support for implicit typename/template (even disabling
extensions), so they can't help on this regard.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |UNCONFIRMED
Resolution|INVALID |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17000
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/17000] parse error calling member template function of non-lvalue from within template class member
2004-08-12 11:08 [Bug c++/17000] New: " stefaandr at hotmail dot com
2004-08-12 13:29 ` [Bug c++/17000] " bangerth at dealii dot org
2004-08-12 13:41 ` giovannibajo at libero dot it
@ 2004-08-12 14:20 ` bangerth at dealii dot org
2004-08-12 14:34 ` giovannibajo at libero dot it
` (2 subsequent siblings)
5 siblings, 0 replies; 12+ messages in thread
From: bangerth at dealii dot org @ 2004-08-12 14:20 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2004-08-12 14:20 -------
Your specialization is of course invalid the way you
write it: it needs at least to have the same return type.
The question I have is different: of course the call to
get_a() is dependent, but its return type 'a' is not, and
we know that it can never be since the call to get_a can
be looked up at template definition time, so the return
type 'a' is fixed at that time. So if we know the return
type, why would we need the '.template' disambiguation?
BTW: icc8 accepts the code with or without disambiguation,
even in strict mode. Now, whether that means something is surely
a different matter :)
W.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17000
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/17000] parse error calling member template function of non-lvalue from within template class member
2004-08-12 11:08 [Bug c++/17000] New: " stefaandr at hotmail dot com
2004-08-12 13:29 ` [Bug c++/17000] " bangerth at dealii dot org
@ 2004-08-12 13:41 ` giovannibajo at libero dot it
2004-08-12 14:20 ` bangerth at dealii dot org
` (3 subsequent siblings)
5 siblings, 0 replies; 12+ messages in thread
From: giovannibajo at libero dot it @ 2004-08-12 13:41 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From giovannibajo at libero dot it 2004-08-12 13:41 -------
No, get_a() is a dependent call, since it's a short form for this->get_a().
Consider what happens if you specialize get_a after the definition of func(),
such as:
template <>
void b<float>::get_a() {}
The compiler is right, you have to specify that "func2" is a member template of
whatever get_a() returned, so you need an explicit "template" keyword.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17000
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/17000] parse error calling member template function of non-lvalue from within template class member
2004-08-12 11:08 [Bug c++/17000] New: " stefaandr at hotmail dot com
@ 2004-08-12 13:29 ` bangerth at dealii dot org
2004-08-12 13:41 ` giovannibajo at libero dot it
` (4 subsequent siblings)
5 siblings, 0 replies; 12+ messages in thread
From: bangerth at dealii dot org @ 2004-08-12 13:29 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2004-08-12 13:29 -------
I would concur, but am not quite sure. It would seem as if
get_a() is a non-dependent call producing just an object of
type 'a', so one should be able to simply call a member
template as you do. What gcc expects, instead, is that you write
get_a().template func2<int> ();
Giovanni, what do you say?
W.
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |giovannibajo at gcc dot gnu
| |dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17000
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2024-02-16 17:56 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <bug-17000-4@http.gcc.gnu.org/bugzilla/>
2021-07-24 1:43 ` [Bug c++/17000] parse error calling member template function of non-lvalue from within template class member pinskia at gcc dot gnu.org
2024-02-16 17:56 ` mpolacek at gcc dot gnu.org
[not found] <bug-17000-3238@http.gcc.gnu.org/bugzilla/>
2007-03-18 1:06 ` matt at galloway dot me dot uk
2007-03-18 6:12 ` pinskia at gcc dot gnu dot org
2007-03-18 11:02 ` matt at galloway dot me dot uk
2007-04-20 17:51 ` ddneilson at gmail dot com
2004-08-12 11:08 [Bug c++/17000] New: " stefaandr at hotmail dot com
2004-08-12 13:29 ` [Bug c++/17000] " bangerth at dealii dot org
2004-08-12 13:41 ` giovannibajo at libero dot it
2004-08-12 14:20 ` bangerth at dealii dot org
2004-08-12 14:34 ` giovannibajo at libero dot it
2004-08-12 14:58 ` pinskia at gcc dot gnu dot org
2004-08-12 15:15 ` bangerth at dealii dot org
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).