commit 72b9617f4d2ec4af8ab9fdcd29b3c9d065059429 Author: Jason Merrill Date: Mon Jul 11 15:36:04 2016 -0400 PR c++/71718 - infinite recursion and alias template * pt.c (push_tinst_level_loc): Set at_eof before fatal_error. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index a1b0ca9..830ff0a 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -9132,10 +9132,12 @@ push_tinst_level_loc (tree d, location_t loc) if (tinst_depth >= max_tinst_depth) { + /* Tell error.c not to try to instantiate any templates. */ + at_eof = 2; fatal_error (input_location, "template instantiation depth exceeds maximum of %d" - " (use -ftemplate-depth= to increase the maximum)", - max_tinst_depth); + " (use -ftemplate-depth= to increase the maximum)", + max_tinst_depth); return false; } diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-55.C b/gcc/testsuite/g++.dg/cpp0x/alias-decl-55.C new file mode 100644 index 0000000..c6d7ae6 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/alias-decl-55.C @@ -0,0 +1,23 @@ +// PR c++/71718 +// { dg-do compile { target c++11 } } + +template +class A : T{}; + +template +using sp = A; + +struct Base {}; + +template +const sp +rec() // { dg-error "depth" } +{ + return rec(); +} + +static void f(void) { + rec(); +} + +// { dg-prune-output "compilation terminated" }