This is the mail archive of the gcc@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]

Question on visible scope in template declaration


Hello list,

The following code is rejected by GCC but accepted by Clang:

template <class T>
auto f(T v) -> decltype(g(v));

int g(int) { return 0; }

template <class T>
auto f(T v) -> decltype(g(v))
{
  return g(v) + 1;
}

int main()
{
  return f(0);
}

Error message at http://ideone.com/Vn79Hm.

Basically the problem comes down to which is the visible scope in that trailing return type decltype(g(v)), where GCC uses the point of declaration but Clang uses the point of definition. g is a dependent name here, and the standard says "template definition context" should be used; but I am not very sure about the wording. I suspect this to be a GCC bug, but not sure, so asking here first.

--
Carl Lei (XeCycle)
Department of Physics and Astronomy, SJTU


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