public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/31407]  New: [4.3 Regression] undefined reference to `vtable for x'
@ 2007-03-30 22:48 tbm at cyrius dot com
  2007-03-30 22:58 ` [Bug c++/31407] " pinskia at gcc dot gnu dot org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: tbm at cyrius dot com @ 2007-03-30 22:48 UTC (permalink / raw)
  To: gcc-bugs

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 <getopt.h>
#include <string>

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 <cstdlib>
#include <sys/time.h>

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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/31407] [4.3 Regression] undefined reference to `vtable for x'
  2007-03-30 22:48 [Bug c++/31407] New: [4.3 Regression] undefined reference to `vtable for x' tbm at cyrius dot com
@ 2007-03-30 22:58 ` pinskia at gcc dot gnu dot org
  2007-03-30 23:02 ` tbm at cyrius dot com
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-03-30 22:58 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2007-03-30 23:58 -------
There is no `#pragma implementation ' so I don't think this is a bug.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31407


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/31407] [4.3 Regression] undefined reference to `vtable for x'
  2007-03-30 22:48 [Bug c++/31407] New: [4.3 Regression] undefined reference to `vtable for x' tbm at cyrius dot com
  2007-03-30 22:58 ` [Bug c++/31407] " pinskia at gcc dot gnu dot org
@ 2007-03-30 23:02 ` tbm at cyrius dot com
  2007-03-30 23:06 ` tbm at cyrius dot com
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: tbm at cyrius dot com @ 2007-03-30 23:02 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from tbm at cyrius dot com  2007-03-31 00:01 -------
Any idea why it works when I remove completely unrelated lines, e.g.

    if (c == -1)
      break;

Is this just a coincidence?


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31407


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/31407] [4.3 Regression] undefined reference to `vtable for x'
  2007-03-30 22:48 [Bug c++/31407] New: [4.3 Regression] undefined reference to `vtable for x' tbm at cyrius dot com
  2007-03-30 22:58 ` [Bug c++/31407] " pinskia at gcc dot gnu dot org
  2007-03-30 23:02 ` tbm at cyrius dot com
@ 2007-03-30 23:06 ` tbm at cyrius dot com
  2007-03-31  7:56 ` schwab at suse dot de
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: tbm at cyrius dot com @ 2007-03-30 23:06 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from tbm at cyrius dot com  2007-03-31 00:06 -------
(In reply to comment #1)
> There is no `#pragma implementation ' so I don't think this is a bug.

This doesn't seem to help either.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31407


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/31407] [4.3 Regression] undefined reference to `vtable for x'
  2007-03-30 22:48 [Bug c++/31407] New: [4.3 Regression] undefined reference to `vtable for x' tbm at cyrius dot com
                   ` (2 preceding siblings ...)
  2007-03-30 23:06 ` tbm at cyrius dot com
@ 2007-03-31  7:56 ` schwab at suse dot de
  2007-03-31  9:22 ` tbm at cyrius dot com
  2007-04-01  0:01 ` pinskia at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: schwab at suse dot de @ 2007-03-31  7:56 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from schwab at suse dot de  2007-03-31 08:56 -------
You need to put it at the top of the file.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31407


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/31407] [4.3 Regression] undefined reference to `vtable for x'
  2007-03-30 22:48 [Bug c++/31407] New: [4.3 Regression] undefined reference to `vtable for x' tbm at cyrius dot com
                   ` (3 preceding siblings ...)
  2007-03-31  7:56 ` schwab at suse dot de
@ 2007-03-31  9:22 ` tbm at cyrius dot com
  2007-04-01  0:01 ` pinskia at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: tbm at cyrius dot com @ 2007-03-31  9:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from tbm at cyrius dot com  2007-03-31 10:22 -------
(In reply to comment #4)
> You need to put it at the top of the file.

That works.  Still, a better diagnostic would be nice if that's possible.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31407


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/31407] [4.3 Regression] undefined reference to `vtable for x'
  2007-03-30 22:48 [Bug c++/31407] New: [4.3 Regression] undefined reference to `vtable for x' tbm at cyrius dot com
                   ` (4 preceding siblings ...)
  2007-03-31  9:22 ` tbm at cyrius dot com
@ 2007-04-01  0:01 ` pinskia at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-04-01  0:01 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from pinskia at gcc dot gnu dot org  2007-04-01 01:00 -------
Read:
http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/C_002b_002b-Interface.html


This is all documented there.  Really "#pragma interface"/"#pragma
implementation" is useless for 99% of the code now adays because of comdat. 
Yes people use older compilers but this is not our issue.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31407


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2007-04-01  0:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-30 22:48 [Bug c++/31407] New: [4.3 Regression] undefined reference to `vtable for x' tbm at cyrius dot com
2007-03-30 22:58 ` [Bug c++/31407] " pinskia at gcc dot gnu dot org
2007-03-30 23:02 ` tbm at cyrius dot com
2007-03-30 23:06 ` tbm at cyrius dot com
2007-03-31  7:56 ` schwab at suse dot de
2007-03-31  9:22 ` tbm at cyrius dot com
2007-04-01  0:01 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).