From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1034 invoked by alias); 10 Oct 2002 21:22:59 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 982 invoked from network); 10 Oct 2002 21:22:56 -0000 Received: from unknown (HELO soliton.integrable-solutions.net) (193.51.208.222) by sources.redhat.com with SMTP; 10 Oct 2002 21:22:56 -0000 Received: (from gdr@localhost) by soliton.integrable-solutions.net (8.11.6/8.11.6/SuSE Linux 0.5) id g9ALMW403967; Thu, 10 Oct 2002 23:22:32 +0200 To: Matt Austern Cc: gcc@gcc.gnu.org Subject: Re: When to emit the vtable for a class template References: From: Gabriel Dos Reis In-Reply-To: Matt Austern's message of "Thu, 10 Oct 2002 14:11:47 -0700" Organization: Integrable Solutions Mime-Version: 1.0 (generated by tm-edit 7.106) Content-Type: text/plain; charset=US-ASCII Date: Thu, 10 Oct 2002 15:24:00 -0000 Message-ID: X-SW-Source: 2002-10/txt/msg00566.txt.bz2 Matt Austern writes: [...] | Consider the following translation unit: | | template struct X { | virtual void foo(); | virtual ~X(); | }; | | template void X::foo() { } | | | X* xyzzy(X* p) { | return p + 1; | } | | Clearly X must be instantiated. Hmm, if "instantiated" is used as the C++ standard uses it, then I'm not clear why X ought to be instantiated. AFAIK, only the template-id 'X' needs to be "instantiated". Consider struct A; A* foo(X* p) { return p + 1; } That is a valid construct that does not need completeness of type A and the situation is not different from the X case. | However, compiling this | with -S and looking at the assembly code, I'm not seeing | X's vtable. I fear the vtable for X does not need to be emitted. | So, my question stands: under what circumstances does the | compiler emit a vtable for a polymorphic class template? I'm however unable to give an informed answer to this question. | Is | the answer the same as what the ABI specification says it | should be? I would expect so. -- Gaby