This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/29844] New: Lookup of template dependent function fails in namespace
- From: "ian at airs dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 15 Nov 2006 17:47:23 -0000
- Subject: [Bug c++/29844] New: Lookup of template dependent function fails in namespace
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
I believe this short C++ code should compile without errors:
class c;
template<typename T> class tm { public: const T& g() const; };
namespace n {
template <class T> int fn(const tm<T> &v) { return fn(v.g()); }
int fn(const c *p);
}
int main() { tm<c *> v; return n::fn(v); }
Instead, I get
foo.cc: In function ?int n::fn(const tm<T>&) [with T = c*]?:
foo.cc:7: instantiated from here
foo.cc:4: error: no matching function for call to ?fn(c* const&)?
Here fn is being called recursively with an argument which depends on the
template type, so it should be looked up at template instantiation time, not at
template definition time. So the matching call should be found.
By comparison, this code compiles without error:
class c;
template<typename T> class tm { public: const T& g() const; };
namespace n {
int fn(const c *p);
template <class T> int fn(const tm<T> &v) { return fn(v.g()); }
}
int main() { tm<c *> v; return n::fn(v); }
This is not surprising, since the function declaration can now be seen at
template definition time.
However, this code also compiles without error:
class c;
template<typename T> class tm { public: const T& g() const; };
template <class T> int fn(const tm<T> &v) { return fn(v.g()); }
int fn(const c *p);
int main() { tm<c *> v; return fn(v); }
Here the declaration is only available at template instantiation time, yet it
works.
So it seems to be me that there may be a bug related to namespaces when
handling lookup of template dependent types. I haven't investigated further.
--
Summary: Lookup of template dependent function fails in namespace
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: ian at airs dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29844