g++
does have such an option, but it isn't enabled by default on kubuntu, for example.
The following is part of gcc/cp/tree.c
from gcc-4.8.1
(and is therefore licensed under the GPL):
void
cxx_print_statistics (void)
{
print_search_statistics ();
print_class_statistics ();
print_template_statistics ();
if (GATHER_STATISTICS)
fprintf (stderr, "maximum template instantiation depth reached: %d\n",
depth_reached);
}
You can get those statistics when adding -fdump-statistics -fstats
to your command line, but GATHER_STATISTICS
has to be enabled at the time you compile gcc
, so you will probably have to rebuild gcc
in order to get the functionality you are looking for.