https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66153
--- Comment #9 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Here is the full on reduced testcase (the previous one was wrong): template<class obj> struct Container { obj data[1]; }; template<class obj> struct Recursive {}; template<int N,class obj> obj function(const obj &arg) { return obj{}; } template<int N,class obj> auto function(const Container<obj> & arg) -> Container<decltype(function<N>(arg.data[0]))> { Container<decltype(function<N>(arg.data[0]))> ret; return ret; } int main(int argc,char **argv) { Container<Recursive<Recursive<int> > > array; function<1>(array); }