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++/51951] Template function dependent name resolution fails


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.


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