This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Debugging missing vtables
* Ian Lance Taylor:
> Florian Weimer <fw@deneb.enyo.de> writes:
>
>> On some large application (not written by me), GCC 4.0 does not emit
>> some vtables, and link errors are the result.
>>
>> If I understand things correctly, a certain member is deemed the
>> controlling member, and the vtable is emitted in the translation unit
>> which contains this member.
>>
>> Is there a way to cause GCC to print this member? I think this would
>> help me to debug this issue. (It's probably a bug in the application,
>> but I'm not completely sure.)
>
>>From the documentation:
>
> C++ virtual functions are implemented in most compilers using a lookup
> table, known as a vtable. The vtable contains pointers to the virtual
> functions provided by a class, and each object of the class contains a
> pointer to its vtable (or vtables, in some multiple-inheritance
> situations). If the class declares any non-inline, non-pure virtual
> functions, the first one is chosen as the ``key method'' for the class,
> and the vtable is only emitted in the translation unit where the key
> method is defined.
>
> I don't know of any way to print the member.
It wouldn't have helped in this case anyway.
The code looks like this:
template <int I>
struct Foo
{
virtual ~Foo();
};
template struct Foo<5>;
template <int I>
Foo<I>::~Foo()
{
}
int
main()
{
return 0;
}
This used to work with GCC 3.4. It would be nice if GCC 4.x could
issue some warning, instead of running into a link error later. (It's
probably not a GCC bug because the program is invalid and the error is
detected at link time.)
Does this issue look familiar? Is there a PR about it?