public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/24161] New: Lookup of template member function finds global type.
@ 2005-10-01 13:59 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
  0 siblings, 1 reply; 15+ messages in thread
From: redi at gcc dot gnu dot org @ 2005-10-01 13:59 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1729 bytes --]

// A template class.
template< typename, typename > struct f {};

// A template function that calls a member template function.
template< typename T >
void call_f( T& t )
{
   t.template f< int >();
   // t.T::template f< int >();  // this line works
}


struct F {
    template <typename> void f() {}
};

int main()
{
    F obj;
    call_f(obj);
}

GCCs 3.4 - 4.1 error with:

phil2.cc: In function ‘void call_f(T&)’:
phil2.cc:8: error: wrong number of template arguments (1, should be 2)
phil2.cc:2: error: provided for ‘template<class, class> struct f’


Shouldn't the lookup of the id-expression "template f<int>" be done in the scope
of T according to 3.4.5/2, so shouldn't it be ignoring ::f ?

If you qualify the function call with "T::" it works as expected. 
If either ::f or ::call_f() is not a template, it works.

I expect the template-id "template f<int>" to be dependent on T, so get looked
up at the point of instantiation, in the scope of F, finding F::f.  It seems
that either it isn't dependent (in which case it should not find F::F if you
comment out the declaration of ::f) or something means that lookup of a
template, within a template disregards 3.4.5/2.  Or it's a bug, but I'm not
convinced I haven't overlooked something.

-- 
           Summary: Lookup of template member function finds global type.
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: redi at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org


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


^ permalink raw reply	[flat|nested] 15+ messages in thread
[parent not found: <bug-24161-5876@http.gcc.gnu.org/bugzilla/>]
[parent not found: <bug-24161-4@http.gcc.gnu.org/bugzilla/>]

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

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-10-01 13:59 [Bug c++/24161] New: Lookup of template member function finds global type 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
     [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
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

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