I found this part of the changes slated for the GCC 5 release series mildly interesting:
Excessive template instantiation depth is now a fatal error. This prevents excessive diagnostics that usually do not help to identify the problem.Although as of earlier this month GCC 5 feature development is now over, I have not yet used or even built it yet so I'm curious about what this means as it seemed to be a fatal error already. For example, compiling a source file with a known template recursion depth of 1000 without the
-ftemplate-depth
option results in:$ gcc -std=c++11 -Wall -pedantic -lstdc++ deep.cpp deep.cpp:14:10: error: template instantiation depth exceeds maximum of 900 (use -ftemplate-depth= to increase the maximum) instantiating ‘struct PrevMultiple<99>’ deep.cpp:14:10: recursively required from ‘struct PrevMultiple<998>’ deep.cpp:14:10: required from ‘struct PrevMultiple<999>’ deep.cpp:26:51: required from here deep.cpp:14:10: error: incomplete type ‘PrevMultiple<99>’ used in nested name specifierNote that the error occurred (and compilation stopped) while there were still 100 recursions remaining. No attempt was made to descend into the remaining instantiations (as VC++ will try to do, complaining the entire time), so how is that not a fatal error already? And what is "excessive" about those diagnostics? They not only tell you exactly what the problem is, they also tell you how to fix it if it's not an accidental runaway recursive expansion.
I can't imagine that '-ftemplate-depth
' is going away, so what does that change even mean? A cryptic error message more in line with other gcc
messages will replace the perfectly clear and helpful diagnostics currently displayed?