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.

Reply via email to