This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/44841] New: Add suggestion to "undefined reference to `vtable for ...´"
- From: "phresnel at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 6 Jul 2010 15:01:13 -0000
- Subject: [Bug c++/44841] New: Add suggestion to "undefined reference to `vtable for ...´"
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
It was today that I stumbled over the seemingly simple situation of tweaking
some bits of an interface class.
Upon doing that, I got an undefined reference to a vtable.
I made clean and made my application. Nothing changed. Then I checked again the
interface and didn't find anything. Then I checked all derivations. Nothing.
Of course it was just me who has been a fool for not recognising a missing
character-tuple " = 0" behind a function signature, as in:
struct IFoo {
virtual ~IFoo() {}
virtual void frob (); // <-- missing pure specifier
};
struct Foo : IFoo { virtual void frob () {} };
int main () {
IFoo *f = new Foo();
f->frob();
delete f;
}
The exact error message was
"undefined reference to `vtable for IFoo'"
As this costed me a not irrelevant amount of time, and I wouldn't describe me
as unexperienced, my proposal would be to add a suggestion in case of undefined
vtable, in the spirit of
undefined reference to `vtable for IFoo'
Suggestions:
* Ensure that no (pure) member function of `IFoo' became unintentionally
non-pure because of a missing or deleted `= 0'
* Ensure that all non-pure member functions are defined *and* linked
Of course there exist more reasons for such vtable errors, but I think it can
already improve productivity to just enumerate the most common mistakes.
Of course I learned my lesson for now, but probably I'll forget it again in
some months, and then, "undefined reference to `vtable for IFoo'" alone will
again not be of much help, as described in the introduction to this report.
--
Summary: Add suggestion to "undefined reference to `vtable for
...´"
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: phresnel at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44841