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]

Re: When to emit the vtable for a class template


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


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