This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: When to emit the vtable for a class template
- From: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- To: Matt Austern <austern at apple dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: 10 Oct 2002 23:43:06 +0200
- Subject: Re: When to emit the vtable for a class template
- Organization: Integrable Solutions
- References: <38CE5C1C-DC98-11D6-80E4-00039390D9E0@apple.com>
Matt Austern <austern@apple.com> writes:
| On Thursday, October 10, 2002, at 02:22 PM, Gabriel Dos Reis wrote:
|
| > Matt Austern <austern@apple.com> writes:
| >
| > [...]
| >
| > | Consider the following translation unit:
| > |
| > | template<class T> struct X {
| > | virtual void foo();
| > | virtual ~X();
| > | };
| > |
| > | template <class T> void X<T>::foo() { }
| > |
| > |
| > | X<int>* xyzzy(X<int>* p) {
| > | return p + 1;
| > | }
| > |
| > | Clearly X<int> must be instantiated.
| >
| > Hmm, if "instantiated" is used as the C++ standard uses it, then I'm
| > not clear why X<int> ought to be instantiated. AFAIK, only the
| > template-id 'X<int>' needs to be "instantiated".
|
| 5.7, paragraph 1: "For addition ... one operand shall be a pointer to
| a completely defined object type and the other shall have integral
| or enumeration type".
Oops, I spoke non-sense. Please, ignore my previous message -- I
should have rethought the issue before pressing the send key.
[...]
| My (possibly incorrect) reading of the ABI specification is that an
| implicit instantiation of a polymorphic class template results in
| having its vtable emitted.
I think your interpretation makes sense and you have a valid point.
-- Gaby