I have a class which is NOT, as far as I can see, polymorphic.

It doesn't inherit from any other class and none of its methods are
declared virtual.  The class implementation and all its callers all
compile just fine.

Is there some other way that a class can be thought to be virtual,
stealthily (say by its usage in some other class or something)?

The problem is that when I link this class I get a linker error from
gold:

  MyClass.h:25: error: undefined reference to 'vtable for MyClass'
ld: the vtable symbol may be undefined because the class is missing its
key function

Line 25 is the first method in the class (a constructor).

Sure enough if I use nm -C on the other object files I'm linking, I see
things like this:

   foo.o:  U vtable for MyClass

How can I figure out why the compiler decides, while compiling foo.cxx,
that MyClass is virtual and needs a vtable when as far as I can tell
it's not (if I use nm on MyClass.o I see no hints of vtable etc.)

This is with GCC 10.2 / binutils 2.35.1 (x86_64)

Reply via email to