public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/24161] [3.4/4.0/4.1 Regression] Lookup of template member function finds global type.
       [not found] <bug-24161-5876@http.gcc.gnu.org/bugzilla/>
@ 2005-10-02 16:25 ` redi at gcc dot gnu dot org
  2005-10-02 22:12 ` mmitchel at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: redi at gcc dot gnu dot org @ 2005-10-02 16:25 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from redi at gcc dot gnu dot org  2005-10-02 16:25 -------
P.S. in case it isn't obvious, the last paragraph should say "... F::f ..."
rather than "... F::F ..."


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24161


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

* [Bug c++/24161] [3.4/4.0/4.1 Regression] Lookup of template member function finds global type.
       [not found] <bug-24161-5876@http.gcc.gnu.org/bugzilla/>
  2005-10-02 16:25 ` [Bug c++/24161] [3.4/4.0/4.1 Regression] Lookup of template member function finds global type redi at gcc dot gnu dot org
@ 2005-10-02 22:12 ` mmitchel at gcc dot gnu dot org
  2005-10-03  0:16 ` mmitchel at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2005-10-02 22:12 UTC (permalink / raw)
  To: gcc-bugs



-- 

mmitchel at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |mark at codesourcery dot com
                   |dot org                     |
             Status|NEW                         |ASSIGNED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24161


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

* [Bug c++/24161] [3.4/4.0/4.1 Regression] Lookup of template member function finds global type.
       [not found] <bug-24161-5876@http.gcc.gnu.org/bugzilla/>
  2005-10-02 16:25 ` [Bug c++/24161] [3.4/4.0/4.1 Regression] Lookup of template member function finds global type redi at gcc dot gnu dot org
  2005-10-02 22:12 ` mmitchel at gcc dot gnu dot org
@ 2005-10-03  0:16 ` mmitchel at gcc dot gnu dot org
  2005-10-03 16:55 ` redi at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2005-10-03  0:16 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from mmitchel at gcc dot gnu dot org  2005-10-03 00:16 -------
Until DR228 the name following ".template" had to be a member template, so the
code would have been invalid on those grounds.

However, even after DR228, I don't think this is valid code.

The name lookup done after ".template" must include templates in the global
scope; DR 228 makes that clear.

EDG 3.6 rejects the program in its strict mode, as well, giving two messages:

"pr24161.cpp", line 7: error: name following "template" must be a member
          template
     t.template f< int >();
                ^

"pr24161.cpp", line 7: error: too few arguments for class template "f"
     t.template f< int >();
                       ^


-- 

mmitchel at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24161


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

* [Bug c++/24161] [3.4/4.0/4.1 Regression] Lookup of template member function finds global type.
       [not found] <bug-24161-5876@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2005-10-03  0:16 ` mmitchel at gcc dot gnu dot org
@ 2005-10-03 16:55 ` redi at gcc dot gnu dot org
  2005-10-03 16:56 ` redi at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: redi at gcc dot gnu dot org @ 2005-10-03 16:55 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from redi at gcc dot gnu dot org  2005-10-03 16:54 -------
> Until DR228 the name following ".template" had to be a member template, so the
> code would have been invalid on those grounds.

Erm, the name following .template *is* a member template, that's my whole
point!  :-)

I don't understand why DR228 applies, that is about whether non-member
templates can follow the .template syntax, not about whether 3.4.5 para 2
applies to templates.  Additionally, I believe the apparently correct behaviour
that resulted in my bug report makes the use of "template" even harder to teach
- something that was apparently a motivation for DR228.  It also means that the
template function "f" is dependent on include ordering and whether a global "f"
has been declared.

However, I'll take the question to a more appropriate forum and try to get an
explanation there, rather than banging on about it here.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24161


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

* [Bug c++/24161] [3.4/4.0/4.1 Regression] Lookup of template member function finds global type.
       [not found] <bug-24161-5876@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2005-10-03 16:55 ` redi at gcc dot gnu dot org
@ 2005-10-03 16:56 ` redi at gcc dot gnu dot org
  2005-10-03 17:06 ` pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: redi at gcc dot gnu dot org @ 2005-10-03 16:56 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from redi at gcc dot gnu dot org  2005-10-03 16:56 -------
Oops, sorry, I meant:

template function "call_f" is dependent on include ordering and whether a
global "f" has been declared.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24161


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

* [Bug c++/24161] [3.4/4.0/4.1 Regression] Lookup of template member function finds global type.
       [not found] <bug-24161-5876@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2005-10-03 16:56 ` redi at gcc dot gnu dot org
@ 2005-10-03 17:06 ` pinskia at gcc dot gnu dot org
  2005-10-03 17:08 ` mark at codesourcery dot com
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-10-03 17:06 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from pinskia at gcc dot gnu dot org  2005-10-03 17:06 -------
For what is worth Comeau rejects the code:


"ComeauTest.c", line 8: error: name following "template" must be a member
template
     t.template f< int >();
                ^

"ComeauTest.c", line 8: error: too few arguments for class template "f"
     t.template f< int >();
                       ^

"ComeauTest.c", line 8: warning: ambiguous class member reference -- function
          template "F::f" (declared at line 14) used in preference to class
          template "f" (declared at line 2)
     t.template f< int >();
                ^
          detected during instantiation of "void call_f(T &) [with T=F]" 

Removing the template class above does "fix" it too there.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24161


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

* [Bug c++/24161] [3.4/4.0/4.1 Regression] Lookup of template member function finds global type.
       [not found] <bug-24161-5876@http.gcc.gnu.org/bugzilla/>
                   ` (5 preceding siblings ...)
  2005-10-03 17:06 ` pinskia at gcc dot gnu dot org
@ 2005-10-03 17:08 ` mark at codesourcery dot com
  2005-10-03 17:54 ` redi at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: mark at codesourcery dot com @ 2005-10-03 17:08 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from mark at codesourcery dot com  2005-10-03 17:08 -------
Subject: Re:  [3.4/4.0/4.1 Regression] Lookup of template member
 function finds global type.

redi at gcc dot gnu dot org wrote:
> ------- Comment #4 from redi at gcc dot gnu dot org  2005-10-03 16:54 -------
> 
>>Until DR228 the name following ".template" had to be a member template, so the
>>code would have been invalid on those grounds.
> 
> 
> Erm, the name following .template *is* a member template, that's my whole
> point!  :-)

:-)

The problem is that we can't do the lookup, because the expression
before the "." is dependent.  But, we still have to do global-scope
lookup, because "t.template S<T>::f()" would be valid, if "S" were a
global template, and redundant "template" keywords are specifically allowed.

I do see your point, though.  It's possible that the lookup after
"t.template" should be restricted so that if "t" is dependent, then no
lookup is performed.

> However, I'll take the question to a more appropriate forum and try to get an
> explanation there, rather than banging on about it here.

If you do get a DR opened about this, please let me know!


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24161


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

* [Bug c++/24161] [3.4/4.0/4.1 Regression] Lookup of template member function finds global type.
       [not found] <bug-24161-5876@http.gcc.gnu.org/bugzilla/>
                   ` (6 preceding siblings ...)
  2005-10-03 17:08 ` mark at codesourcery dot com
@ 2005-10-03 17:54 ` redi at gcc dot gnu dot org
  2005-10-04 21:43 ` anthony dot ajw at gmail dot com
  2005-10-05 21:16 ` redi at gcc dot gnu dot org
  9 siblings, 0 replies; 14+ messages in thread
From: redi at gcc dot gnu dot org @ 2005-10-03 17:54 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from redi at gcc dot gnu dot org  2005-10-03 17:54 -------
Aah, gotcha.  I now see why the global scope has to be considered, and why
DR228 is relevant.  Thanks!  I still think it's of dubious value having the
standard defined like that, so might take it to the UK panel and see if anyone
there cares about it.

Andrew, another interesting variation is to add two template arguments to the
function call.  Then you don't get the "wrong number of template arguments" you
get one saying "invalid use of struct f", which is because it's not valid to
refer to a typename there - but then everyone except the compiler already knew
that!  ;-)


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24161


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

* [Bug c++/24161] [3.4/4.0/4.1 Regression] Lookup of template member function finds global type.
       [not found] <bug-24161-5876@http.gcc.gnu.org/bugzilla/>
                   ` (7 preceding siblings ...)
  2005-10-03 17:54 ` redi at gcc dot gnu dot org
@ 2005-10-04 21:43 ` anthony dot ajw at gmail dot com
  2005-10-05 21:16 ` redi at gcc dot gnu dot org
  9 siblings, 0 replies; 14+ messages in thread
From: anthony dot ajw at gmail dot com @ 2005-10-04 21:43 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from anthony dot ajw at gmail dot com  2005-10-04 21:43 -------
The name following "t." must be the name of a member of either T, or one of its
base classes.

t.template f<int> can only refer to a global template f if it is then followed
by a nested name specifier (e.g. t.template f<int>::X) so that it is a
qualified name for member of T.

This is just the same as t.f always refers to a member, even if there is a
non-member f in scope, unless one writes t.f::X (for some X).

t.template f<int>() can thus only refer to a member template, and the global
template should not be considered.


-- 

anthony dot ajw at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |anthony dot ajw at gmail dot
                   |                            |com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24161


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

* [Bug c++/24161] [3.4/4.0/4.1 Regression] Lookup of template member function finds global type.
       [not found] <bug-24161-5876@http.gcc.gnu.org/bugzilla/>
                   ` (8 preceding siblings ...)
  2005-10-04 21:43 ` anthony dot ajw at gmail dot com
@ 2005-10-05 21:16 ` redi at gcc dot gnu dot org
  9 siblings, 0 replies; 14+ messages in thread
From: redi at gcc dot gnu dot org @ 2005-10-05 21:16 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from redi at gcc dot gnu dot org  2005-10-05 21:16 -------
Yes, I agree with Anthony, DR228 is about nested-name-specifiers, this bug is
about an unqualified-id, so 3.4.5p2 should still apply.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24161


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

* [Bug c++/24161] [3.4/4.0/4.1 Regression] Lookup of template member function finds global type.
       [not found] <bug-24161-4@http.gcc.gnu.org/bugzilla/>
  2011-03-01  1:32 ` redi at gcc dot gnu.org
  2015-01-14 14:57 ` cameron314 at gmail dot com
@ 2015-01-14 15:08 ` redi at gcc dot gnu.org
  2 siblings, 0 replies; 14+ messages in thread
From: redi at gcc dot gnu.org @ 2015-01-14 15:08 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=24161

--- Comment #13 from Jonathan Wakely <redi at gcc dot gnu.org> ---
EDG gives the same error as GCC


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

* [Bug c++/24161] [3.4/4.0/4.1 Regression] Lookup of template member function finds global type.
       [not found] <bug-24161-4@http.gcc.gnu.org/bugzilla/>
  2011-03-01  1:32 ` redi at gcc dot gnu.org
@ 2015-01-14 14:57 ` cameron314 at gmail dot com
  2015-01-14 15:08 ` redi at gcc dot gnu.org
  2 siblings, 0 replies; 14+ messages in thread
From: cameron314 at gmail dot com @ 2015-01-14 14:57 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=24161

Cameron <cameron314 at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |cameron314 at gmail dot com

--- Comment #12 from Cameron <cameron314 at gmail dot com> ---
VS2013 accepts this too.


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

* [Bug c++/24161] [3.4/4.0/4.1 Regression] Lookup of template member function finds global type.
       [not found] <bug-24161-4@http.gcc.gnu.org/bugzilla/>
@ 2011-03-01  1:32 ` redi at gcc dot gnu.org
  2015-01-14 14:57 ` cameron314 at gmail dot com
  2015-01-14 15:08 ` redi at gcc dot gnu.org
  2 siblings, 0 replies; 14+ messages in thread
From: redi at gcc dot gnu.org @ 2011-03-01  1:32 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24161

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |

--- Comment #11 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-03-01 01:32:26 UTC ---
FWIW clang++ accepts this


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

* [Bug c++/24161] [3.4/4.0/4.1 Regression] Lookup of template member function finds global type.
  2005-10-01 13:59 [Bug c++/24161] New: " redi at gcc dot gnu dot org
@ 2005-10-01 15:49 ` pinskia at gcc dot gnu dot org
  0 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-10-01 15:49 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-10-01 15:49 -------
Confirmed, 3.3 accepted the code.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
      Known to fail|                            |4.0.0 4.1.0 3.4.0
      Known to work|                            |3.3.3
   Last reconfirmed|0000-00-00 00:00:00         |2005-10-01 15:49:01
               date|                            |
            Summary|Lookup of template member   |[3.4/4.0/4.1 Regression]
                   |function finds global type. |Lookup of template member
                   |                            |function finds global type.
   Target Milestone|---                         |4.0.3


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24161


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

end of thread, other threads:[~2015-01-14 15:08 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-24161-5876@http.gcc.gnu.org/bugzilla/>
2005-10-02 16:25 ` [Bug c++/24161] [3.4/4.0/4.1 Regression] Lookup of template member function finds global type redi at gcc dot gnu dot org
2005-10-02 22:12 ` mmitchel at gcc dot gnu dot org
2005-10-03  0:16 ` mmitchel at gcc dot gnu dot org
2005-10-03 16:55 ` redi at gcc dot gnu dot org
2005-10-03 16:56 ` redi at gcc dot gnu dot org
2005-10-03 17:06 ` pinskia at gcc dot gnu dot org
2005-10-03 17:08 ` mark at codesourcery dot com
2005-10-03 17:54 ` redi at gcc dot gnu dot org
2005-10-04 21:43 ` anthony dot ajw at gmail dot com
2005-10-05 21:16 ` redi at gcc dot gnu dot org
     [not found] <bug-24161-4@http.gcc.gnu.org/bugzilla/>
2011-03-01  1:32 ` redi at gcc dot gnu.org
2015-01-14 14:57 ` cameron314 at gmail dot com
2015-01-14 15:08 ` redi at gcc dot gnu.org
2005-10-01 13:59 [Bug c++/24161] New: " redi at gcc dot gnu dot org
2005-10-01 15:49 ` [Bug c++/24161] [3.4/4.0/4.1 Regression] " pinskia at gcc dot gnu 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).