From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28976 invoked by alias); 6 Apr 2004 13:41:06 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 28951 invoked by uid 48); 6 Apr 2004 13:41:03 -0000 Date: Tue, 06 Apr 2004 13:41:00 -0000 From: "Clement dot Menier at inrialpes dot fr" To: gcc-bugs@gcc.gnu.org Message-ID: <20040406134048.14865.Clement.Menier@inrialpes.fr> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug c++/14865] New: Instanciation problem of template class derived from virtual base class X-Bugzilla-Reason: CC X-SW-Source: 2004-04/txt/msg00525.txt.bz2 List-Id: Here is the test example that causes the problem. I tried to reduce it to its strict minimum: test.cpp: #include class A { std::string mesg; }; class B : public virtual A {}; template class C : public B {}; int main() { C j; } By compiling it with g++ 3.3.1 (Mandrake 9.2): g++ -O1 -o test test.cpp Returns error: /tmp/ccwnGZD1.o(.text+0x23): In function `main': : undefined reference to `VTT for C' collect2: ld a retourné 1 code d'état d'exécution It seems that it has some problem instanciating the template class C automatically. Here are different tests that DO work (each test is independant): - replace "std::string mesg" by "int mesg" - manually instanciate template class by putting "template class C;" just before the main declaration - Move the delaration of j outside of main (global definition) - Compile with no optimisation (-O0 for example) To clarify things I tested this under: gcc 3.3.1 by Mandrake 9.2 : Failed gcc 3.3.2 by Fedora : Failed gcc 3.3.3 home compiled (with no options) : Failed gcc 3.2.2 by RedHat 9 : Work I thus suspect that this problem appeared with gcc versions 3.3 . It may also be that gcc 3.3 is more strict on the code but I have found no indication to suport this. Clement Menier. -- Summary: Instanciation problem of template class derived from virtual base class Product: gcc Version: 3.3.1 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: Clement dot Menier at inrialpes dot fr CC: gcc-bugs at gcc dot gnu dot org GCC host triplet: i686-px-linux-gnu GCC target triplet: i686-px-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14865