Pregunta

As the title says, is there any compiler logging settings which provides the max instantation deph reached by the compiler during compilation?

If the compilation exceds the max template deph (Which GCC's default value is 900 in C++11 mode), compilation fails. But what I need is to get the maximum template instantation depth which the compiler has reached during a successfull compilation.

¿Fue útil?

Solución

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top