This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/51951] Template function dependent name resolution fails
- From: "basil at list dot ru" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 22 Jan 2012 20:39:41 +0000
- Subject: [Bug c++/51951] Template function dependent name resolution fails
- Auto-submitted: auto-generated
- References: <bug-51951-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51951
--- Comment #2 from Vasily Sukhanov <basil at list dot ru> 2012-01-22 20:39:41 UTC ---
Compilation of attached code fails despite it is accepted by previous GCC
versions.
1 template <class T>
2 class Option {
3 public:
4 bool m_bValid;
5 T m_t;
6 };
7
8 template<class T>
9 void readSingle(Option<T>& opt) {
10 readFromStream(opt.m_bValid);
11 }
12
13 template <class T>
14 void readFromStream(T& t) { }
15
16 int main()
17 {
18 Option<int> o;
19 readSingle(o);
20 }
template_test.cpp: In instantiation of âvoid readSingle(Option<T>&) [with T =
int]â:
template_test.cpp:19:15: required from here
template_test.cpp:10:5: error: âreadFromStreamâ was not declared in this scope,
and no declarations were found by argument-dependent lookup at the point of
instantiation [-fpermissive]
template_test.cpp:14:6: note: âtemplate<class T> void readFromStream(T&)â
declared here, later in the translation unit
I think that instantiation point of readSingle<int> is line 19. readFromStream
in line 10 is dependent on template parameter. Therefore compiler should
perform lookup in context of template instantiation (14.6.4.2). readFromStream
was defined by this point.
I'm on revision 183301.