https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109018
Bug ID: 109018 Summary: decltype of dependent expressions lookup should be done only when doing template function definition Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: nickhuang99 at hotmail dot com Target Milestone: --- In cppreference.com(https://en.cppreference.com/w/cpp/language/function_template#Function_template_overloading) gives this example about dependent expression lookup issue. However, it turns out only GCC has this parsing issue. Both clang and MSVC can solve this with no issue.(https://www.godbolt.org/z/9anx871rr) template<class T> decltype(g(T())) h(); // decltype(g(T())) is a dependent type int g(int); template<class T> decltype(g(T())) h() { // redeclaration of h() uses earlier lookup return g(T()); // although the lookup here does find g(int) } int i = h<int>(); // template argument substitution fails; g(int) // was not in scope at the first declaration of h()