http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58352
Bug ID: 58352 Summary: infinite template instantiation depth errors Product: gcc Version: 4.8.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: 1zeeky at gmail dot com Created attachment 30760 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30760&action=edit testcase The attached testcase yields (seemingly?) infinite output of " integral_constant_test.cpp:8:74: template instantiation depth exceeds maximum of 900 (use -ftemplate-depth= to increase the maximum) substituting ‘template<long unsigned int i> using IndexType = std::integral_constant<long unsigned int, i> [with long unsigned int i = 1ul]’ ". When using -ftemplate-depth=2, there's another message printed, but it still doesn't stop: " integral_constant_test.cpp:8:13: required by substitution of ‘template<class A, long unsigned int index> void foo(IndexType<index>) [with A = int; long unsigned int index = <missing>]’ integral_constant_test.cpp:8:74: template instantiation depth exceeds maximum of 2 (use -ftemplate-depth= to increase the maximum) substituting ‘template<long unsigned int i> using IndexType = std::integral_constant<long unsigned int, i> [with long unsigned int i = 0ul]’ ". The "index = <missing>" looks weird, too. What does that mean? I'm not 100% sure the attached testcase *should* compile. It does when I move the "specialized" foo (for IndexType<1>) before the general-case foo. Compiling with -ftemplate-depth=1 points to the "specialized" version though: " integral_constant_test.cpp:11:13: error: template instantiation depth exceeds maximum of 1 (use -ftemplate-depth= to increase the maximum) substituting ‘template<long unsigned int i> using IndexType = std::integral_constant<long unsigned int, i> [with long unsigned int i = 1ul]’ static void foo(const IndexType<1>) {} ^ integral_constant_test.cpp:11:13: required by substitution of ‘template<class A> void foo(IndexType<1ul>) [with A = int]’ integral_constant_test.cpp:15:25: required from here integral_constant_test.cpp:8:13: error: template instantiation depth exceeds maximum of 1 (use -ftemplate-depth= to increase the maximum) substituting ‘template<long unsigned int i> using IndexType = std::integral_constant<long unsigned int, i> [with long unsigned int i = index]’ static void foo(const IndexType<index>) { foo<int>(IndexType<index + 1>()); } ^ integral_constant_test.cpp:8:13: required by substitution of ‘template<class A, long unsigned int index> void foo(IndexType<index>) [with A = int; long unsigned int index = <missing>]’ integral_constant_test.cpp:15:25: required from here "