This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C++ PATCH] Fix PR6749 (infinite loop generating vtable)


Kriang Lerdsuwanakij wrote:

Hi

This patch fixes an infinite loop: generating a vtable may trigger
template instantiation of function template which is virtual.  This
in turn can cause another vtable to be generated.  And this could
continue forever.  With the patch, the option -ftemplate-depth
to limit the number of such attempts.

Since the function 'instantiate_pending_templates', modified by this
patch, is only used by 'finish_file' and its return type is never used.
I simplify this as well.

Tested on i686-pc-linux-gnu with no regressions. OK for mainline?

OK.

Though, in the specific case of vtables, I suspect we might win bigger if we made vtable creation lazy. Right now, we may be computing a lot of stuff when the closing "}" of a class is encoutered that we probably do not need to do until someone really tries to use the class. Of course, if there always tend to be non-trivial uses of the class, then the current approach wins.

--
Mark Mitchell
CodeSourcery, LLC
(916) 791-8304
mark@codesourcery.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]