This is the mail archive of the gcc@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]

When to emit the vtable for a class template


I'm not sure whether the compiler is following what the ABI
specification (http://www.codesourcery.com/cxx-abi/abi.html)
says.  Entirely possible that I'm misunderstanding what the
ABI document is saying, of course.

The question: if you've got a polymorphic class template,
which translation units do you emit the vtable in?

5.2.3 says that you emit a vtable in the object file where you've
got the definition of the key function, or in every object file if
no key function exists.  5.2.3 may or may not apply to a class
template, of course.

5.2.7 seems to say that you emit a vtable for a class template
in every object file where the class template is instantiated,
irrespective of key functions.

What I'm not completely clear of is what exactly it means to
say that a class template is instantiated.  The most reasonable
interpretation is that the ABI specification is using this language
in the same sense of the C++ Standard, meaning that a class
template is instantiated "if the class type is used in a context that
requires a completely-defined object type or if the completeness
of the class type affects the semantics of the program".  Was that
the intention of the ABI specification and of the implementation?

			--Matt


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