From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27799 invoked by alias); 5 Mar 2008 13:40:30 -0000 Received: (qmail 27786 invoked by uid 22791); 5 Mar 2008 13:40:28 -0000 X-Spam-Check-By: sourceware.org Received: from smtp.ispras.ru (HELO smtp.ispras.ru) (83.149.198.201) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 05 Mar 2008 13:40:03 +0000 Received: from ispserv.ispras.ru (ispserv.ispras.ru [83.149.198.72]) by smtp.ispras.ru (Postfix) with ESMTP id 122CA5D4236 for ; Wed, 5 Mar 2008 16:44:40 +0300 (MSK) Received: from [83.149.198.100] (parock.igroup.ispras.ru [83.149.198.100] (may be forged)) by ispserv.ispras.ru (8.12.8/8.12.8) with ESMTP id m25DdvN8017588 for ; Wed, 5 Mar 2008 16:39:57 +0300 Date: Wed, 05 Mar 2008 13:40:00 -0000 From: Roman Zybin X-Mailer: The Bat! (v3.0.1.33) Professional Reply-To: Roman Zybin Message-ID: <131667623.20080305164000@ispras.ru> To: gcc-help@gcc.gnu.org Subject: in-charge constructors and destructors of abstract classes MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2008-03/txt/msg00041.txt.bz2 The main idea was to prove that there shouldn't be dependency on in-charge constructors and destructors of an abstract classes (since there is no need for their invokations during inheritance), but there is such dependency for QGList class from qt3. The example below only represents QGList structure. Consider the following example: gcc (GCC) 3.4.6 20060404 (Red Hat 3.4.6-3) myclass.h: #ifndef MYCLASS_H #define MYCLASS_H class Myclass { public: virtual int a(); virtual int b(); }; inline int Myclass::a() { return 1; } #endif myclass.cpp: #include "myclass.h" int Myclass::b() { return 2; } test.cpp: #include "myclass.h" int main() { return 0; } Makefile: gcc -fPIC -c myclass.cpp gcc -shared -o libmyclass.so myclass.o gcc -c test.cpp gcc test.o -L. -lmyclass -o test There is the dependency on Myclass::b() method whereas it isn't needed at all. And on binary level we see just reference but no another usage. Relocation section '.rela.plt' at offset 0x658 contains 3 entries: Offset Info Type Sym. Value Sym. Name + Addend 000000500c30 000100000007 R_X86_64_JUMP_SLO 0000000000000000 __libc_start_main + 0 000000500c38 000300000007 R_X86_64_JUMP_SLO 00000000004006d8 _ZN7Myclass1bEv + 0 000000500c40 001000000007 R_X86_64_JUMP_SLO 00000000004006e8 __gxx_personality_v0 + 0 test.asm: 00000000004006d8 <_ZN7Myclass1bEv@plt>: 4006d8: ff 25 5a 05 10 00 jmpq *1049946(%rip) # 500c38 <_GLOBAL_OFFSET_TABLE_+0x20> 4006de: 68 01 00 00 00 pushq $0x1 4006e3: e9 d0 ff ff ff jmpq 4006b8 <_init+0x18> The example has also been tested on gcc (GCC) 4.2.3 (Debian 4.2.3-1) with similar output. So, questions: 1. Is the situation described above regarded as normal or it is just a bug? 2. Are in-charge constructors and destructors of abstract classes really not needed anywhere? 3. If so, should compiler not include them into its output? Regards, Roman