https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66153
--- Comment #10 from Andrew Pinski <pinskia at gcc dot gnu.org> --- A little more reduced: template<class obj> struct c { obj data; }; struct r {}; template<int N,class obj> obj g(const obj &arg); template<int N,class obj> auto g(const c<obj> & arg) -> c<decltype(g<N>(arg.data))> { return c<decltype(g<N>(arg.data))>{}; } int main() { c<r > array; g<1>(array); } ---- CUT ---- Without the guide for the return type, GCC accepts the code. Somehow GCC is messing up g<N>, Removing the template argument N also allows GCC to accept the code.