From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8086 invoked by alias); 30 Mar 2007 22:48:52 -0000 Received: (qmail 7909 invoked by uid 48); 30 Mar 2007 22:48:40 -0000 Date: Fri, 30 Mar 2007 22:48:00 -0000 Subject: [Bug c++/31407] New: [4.3 Regression] undefined reference to `vtable for x' X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "tbm at cyrius dot com" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2007-03/txt/msg02809.txt.bz2 I'm not quite sure what's going on here. *Maybe* this is invalid code, but I belive it's a compiler bug because the error goes away when I remove completely unrelated lines in the program. Anyway, I get the following with 4.3 (it compiles with 4.1): (sid)6870:tbm@em64t: ~] g++ -c -g -O -o test.o test.cc (sid)6871:tbm@em64t: ~] g++ -o x test.o test.o: In function `Timer': /home/tbm/timer.h:13: undefined reference to `vtable for Timer' test.o: In function `Timer::timerEnd()': /home/tbm/timer.h:20: undefined reference to `Timer::ttime() const' test.o: In function `~Timer': /home/tbm/timer.h:16: undefined reference to `vtable for Timer' /home/tbm/timer.h:16: undefined reference to `vtable for Timer' collect2: ld returned 1 exit status test.cc: #include "timer.h" #include #include enum {O_ROW_PLOT, O_VERSION}; static struct option my_options[] = { {"row-plot", 1, 0, O_ROW_PLOT}, {"version", 0, 0, O_VERSION}, {0, 0, 0, 0} }; void test(double d) { } int main (int argc, char *const argv[]) { std::string strOutFile; Timer timerProgram; while (1) { char* endptr; int c = getopt_long (argc, argv, "", my_options, NULL); if (c == -1) break; switch (c) { case O_ROW_PLOT: strtol(optarg, &endptr, 10); break; case O_VERSION: return (0); } } test(timerProgram.timerEnd()); return (0); } timer.h: #ifndef _TIMER_H #define _TIMER_H #pragma interface "timer.h" #include #include class Timer { public: Timer (void) {} ~Timer (void) {} virtual double timerEnd (void) { return ttime(); } protected: double ttime(void) const { struct timeval now; gettimeofday (&now, NULL); return 0; } }; #endif // _TIMER_H -- Summary: [4.3 Regression] undefined reference to `vtable for x' Product: gcc Version: 4.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: tbm at cyrius dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31407