This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: bug in egcs with C++?
- To: oliva at dcc dot unicamp dot br (Alexandre Oliva)
- Subject: Re: bug in egcs with C++?
- From: Joe Buck <jbuck at Synopsys dot COM>
- Date: Fri, 11 Dec 98 10:10:15 PST
- Cc: teunis at computersupportcentre dot com, egcs at cygnus dot com
teunis <teunis@computersupportcentre.com> reported a case where he
gets an undefined virtual function table pointer.
As Alexandre and the g++ FAQ (yes, I know it's out of date) point out,
this is caused because there is a missing definition for the first
non-inline virtual function.
However, perhaps we could give a better diagnostic for this case;
Sun's compiler does. Both g++ and Sun's compiler use the same trick
of emitting the virtual function table definition only in the .o file
that defines the first non-inline virtual function.
Given the test program
------------------------------
class foo {
public:
virtual void method(); // first non-abstract non-inline method
virtual void another_method(); // second non-abstract non-inline method
};
void foo::another_method() {}
main () {
foo bar;
bar.another_method();
}
------------------------------
doing
CC test.cxx
gives
Undefined first referenced
symbol in file
foo::__vtbl ttt.o
[Hint: try checking whether the first non-inlined, non-pure virtual function of class foo is defined]
This hint message has to be produced at link time.
Perhaps the GNU linker and/or collect could be modified to add such
a message if an undefined virtual function table is detected.