Template Metaprogramming Errors Friday 14th September 2007
I’ve been having a very limited play with template metaprogramming and at one point I managed to end up with what appeared to be an infinitely recurring error message. It turns out that it wasn’t, as I was able to redirect all of the stderr output from the compiler to a file. It was, however, 22 megabytes.
$ g++ -Wall -pedantic -std=c++98 -O2 metatest.cc 2>dmp $ wc -c dmp 22163606 dmp
Not bad for a 2k source file.
$ wc -c metatest.cc 2280 metatest.cc
I think a sensible compiler limit prevented the error message from getting “too” large.
metatest.cc:81: error: template instantiation depth exceeds maximum of 500 (use -ftemplate-depth-NN to increase the maximum)