[Bug c++/16636] New: Unable to emit vtable info

miko at stacken dot kth dot se gcc-bugzilla@gcc.gnu.org
Mon Jul 19 19:50:00 GMT 2004


If you define a class with all functions defined inline (but, not inline
functions), then no vtable is emitted for the class. This is problematic since
we generated header files from complete class files for other source files to use.

I believe the following from the info page under -fvtable-thunks=THUNKS-VERSION
explains why:

    "This option also enables a heuristic for controlling emission of
     vtables; if a class has any non-inline virtual functions, the
     vtable will be emitted in the translation unit containing the
     first one of those."

However, the problem is you can't seem to force the vtable to be emitted without
moving the first virtual function's definition outside of the class.

The following testcase shows the problem:

---

#undef EMIT_OUT_OF_CLASS

class A
{
public:

  virtual void foo () { }

  A() {}
};

class B : public A
{
public:

  int b;

#ifdef EMIT_OUT_OF_CLASS
  virtual void foo();
#else
  virtual void foo() { ++b; }
#endif

  virtual
  ~B () { }

  B() : A(), b(0) { }
};

#ifdef EMIT_OUT_OF_CLASS
void B::foo() { ++b; }
#endif


This would seem to be a bug, since there are _no_ non-inline virtual functions,
yet the vtable is still not emitted. Even using -fno-default-inline doesn't help
(although the info entry for that flag would indicate that that behaviour is
correct).

-- 
           Summary: Unable to emit vtable info
           Product: gcc
           Version: 3.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: miko at stacken dot kth dot se
                CC: gcc-bugs at gcc dot gnu dot org


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



More information about the Gcc-bugs mailing list