https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109018
qingzhe huang <nickhuang99 at hotmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|INVALID |FIXED CC| |nickhuang99 at hotmail dot com --- Comment #4 from qingzhe huang <nickhuang99 at hotmail dot com> --- Thank you for your detailed explanation and really appreciate it. My only pleading argument is that the root cause of error is from GCC cannot find correct prototype in "template declaration" which is __NOT__ mandatory for template definition. For example, if I commented out the invalid template function declaration, the parser works without issue. (https://www.godbolt.org/z/1qnTnrE1Y). So, my argument is that GCC report error due to something which is not always necessary. Why cannot parser postpone reporting when actually template definition starts? Even there is not declaration, definition has all information to work. This will pass compilation if template declaration is commented: // 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()