This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/34870] New: template not instantiated for argument-dependent lookup


This code should be legal:

template <typename T>
struct Foo
{
    template <typename Z>
    friend void func(const Foo &) {}
};

void check(const Foo<int> & x)
{
    // Foo<int> weird;  // uncomment this line and all works

    func<int>(x);    // <-- GCC issues an ERROR
}

After a brief discussion on gcc@gcc.gnu.org, it has been concluded that this
sample code should work. Apparently, 'func' should have been found by
argument-dependent lookup, instantiating 'Foo<int>' in the process.

Here are links to backup these claims, as specified in the discussion by people
involved:

- C++ Standard
  - 3.4.2 [basic.lookup.koenig]
  - 14.6.5 [temp.inject]
  - 7.3.1.2 [namespace.memdef] p3
- Vandevoorde and Josuttis' C++ Templates, section 9.2.2
- http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#34

(gcc@gcc.gnu.org thread 'A simple sample code involving templates, friends and
lookup')


-- 
           Summary: template not instantiated for argument-dependent lookup
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dragan at plusplus dot co dot yu


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]