From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5135 invoked by alias); 8 Feb 2006 11:21:37 -0000 Received: (qmail 5116 invoked by uid 48); 8 Feb 2006 11:21:32 -0000 Date: Wed, 08 Feb 2006 11:21:00 -0000 Subject: [Bug c++/26173] New: derived template class with virtual functions implemented in a seperated file does not link X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "alexander dot schmitt at wibu dot com" 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 X-SW-Source: 2006-02/txt/msg00752.txt.bz2 List-Id: The following case can be reproduced with the attached sample. If I have a C++ base class with a virtual function and a derived (template) class and the virtual function is implemented in a own file (-> classb.cpp), the linker does not find the symbol of the function. If the function is implemented inline it will works. The problem seems to be that the object file (classb.o) does not contains the symbol information. The problem seems to be new with gcc 4.0. With gcc 3.3 it works. We have reproduced this with gcc 4.0.1 on Mac OS X and Linux. Using the sample: - unpack attached test.zip - call ./ma.sh in shell terminal (gcc 4.0 envirnment must be set) For me that seems to be a bug because I have not found a compiler switch, etc. to make this working. ================== -> proj.h #include #include class A { public: A() { ma = 0; } // A() virtual ~A() { } // A() virtual int Method1() = 0; protected: int ma; }; // A template class B { public: B() { mb = 0; } // B() virtual ~B() { } // B() virtual int Method1(); protected: T mb; }; // B ================== -> main.cpp #include "proj.h" int main() { B bs; bs.Method1(); B bi; bi.Method1(); B bl; bl.Method1(); return 0; } // main() ================== -> classb.cpp #include "proj.h" template class B; template class B; template class B; template int B::Method1() { printf("pid = %ld\n", (long) getpid()); return 0; } // Method1() ================== -> ma.sh (for Mac OS X) g++ -c -O1 -arch ppc -arch i386 -o main.o main.cpp g++ -c -O1 -arch ppc -arch i386 -o classb.o classb.cpp g++ -o Test1ppc -arch ppc -isysroot /Developer/SDKs/MacOSX10.4u.sdk main.o classb.o -framework Carbon -lstdc++ g++ -o Test1i386 -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk main.o classb.o -framework Carbon -lstdc++ -- Summary: derived template class with virtual functions implemented in a seperated file does not link Product: gcc Version: 4.0.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: alexander dot schmitt at wibu dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26173