What's default value of -ftemplate-depth in GCC 3.4.2?

Jeremy Messenger mezz7 at cox.net
Sun Sep 12 13:16:13 PDT 2004


I am not sure if I am right, but I have a feel that it is possible that  
GCC has forgotten to make the change in the document. Or, maybe someone  
change the GCC 3.4.2's default in FreeBSD? Current, in the document said  
that the default value is 17 but it looks like it's more than 17 to me.


	Set the maximum instantiation depth for template classes to n. A
	limit on the template instantiation depth is needed to detect
	endless recursions during template class instantiation. ANSI/ISO
	C++ conforming programs must not rely on a maximum depth greater
	than 17.

I am working on the games/wesnoth update to 0.8.4 and it will fail build  
on FreeBSD 4.x w/ GCC 2.9x. But, it doesn't fail the build on FreeBSD 5.x  
w/ GCC 3.4.2. The error looks like this:

In file included from display.hpp:17,
                  from font.hpp:19,
                  from about.cpp:15:
/usr/include/g++/stl_iterator.h: In function `void
>::frame *,
animated<unit_animation::frame,void_value<unit_animation::frame> >::frame  
/usr/include/g++/stl_iterator.h:154: template instantiation depth exceeds  
maximum of 17
/usr/include/g++/stl_iterator.h:154:  (use -ftemplate-depth-NN to increase  
the maximum)
/usr/include/g++/stl_iterator.h:154:   instantiating
>::frame *>'

[...goes on...]

So, I added the -ftemplate-depth-20 and it was insteresting that it will  
fail the build on FreeBSD 5.x w/ GCC 3.4.2 now. Changed it to 45 and it  
successed. So... This is what it makes me think that GCC team might have  
change something that is undocumented. Althought, I didn't check the  
changelog lower than 3.4.1. I don't know where the right place for me to  
check the default value of -ftemplate-depth.

The developer of Wesnoth said that his source code doesn't has more than  
10 template depth and said that FreeBSD 4.x's compiler has the bug... I am  
not sure if he is right, since if I put -ftemplate-depth-20 and it will  
fail on GCC 3.4.2 either.

One more thing, how can I count the template depth in any source code?


mezz7 at cox.net  -  mezz at FreeBSD.org
http://www.FreeBSD.org/gnome/  -  gnome at FreeBSD.org

More information about the freebsd-current mailing list