[Bug ld/11793] New: Add suggestion to error "undefined reference to `vtable for XXX'"
I previously entered this to gcc-bugs: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44841 : "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" Maybe a suggestion like "Did you intend to make it a pure virtual function? Add `= 0' then. Otherwise, ensure to define the function." could be added, which in this case would have saved me some productivity. -- Summary: Add suggestion to error "undefined reference to `vtable for XXX'" Product: binutils Version: 2.20 Status: NEW Severity: enhancement Priority: P1 Component: ld AssignedTo: unassigned at sources dot redhat dot com ReportedBy: phresnel at gmail dot com CC: bug-binutils at gnu dot org http://sourceware.org/bugzilla/show_bug.cgi?id=11793 --- You are receiving this mail because: --- You are on the CC list for the bug, or are watching someone who is. ___ bug-binutils mailing list bug-binutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-binutils
[Bug ld/11793] Add suggestion to error "undefined reference to `vtable for XXX'"
--- Additional Comments From phresnel at gmail dot com 2010-07-07 15:24 --- (In reply to comment #1) > If any suggestion is made to the user, it should be to ensure that all > non-pure > virtual functions are defined. Which is what the GCC FAQ already says: > http://gcc.gnu.org/faq.html#vtables This is a perfect suggestion, of course. But the suggestion I am trying to make, sorry if I was unprecise, is that g++ or ld *does* output *some* suggestion (or better error message). I see it as with good documentation: It is optional, but would increase usability and decrease the chill-aways before the matter in question. I know this is not llvm, and I am not a user of llvm, but this is primarily because clang++ is yet incomplete vs. the holy standard, and because gcc optimization seems superiour to any other free compiler. But at three things llvm *seems* to be largely superiour over gcc (incl. some proprietary ones), which is a) error messages [0] b) fast compiles [1] c) low memory usage [1] I'd also prefer gcc from the license viewpoint, but honestly, it is such implementation "detail" that could make quite a few people move away from gcc, at least for on-the-hack compilation (in contrast to complete release builds). [0] http://clang.llvm.org/diagnostics.html [1] http://clang.llvm.org/features.html#performance -- http://sourceware.org/bugzilla/show_bug.cgi?id=11793 --- You are receiving this mail because: --- You are on the CC list for the bug, or are watching someone who is. ___ bug-binutils mailing list bug-binutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-binutils
[Bug ld/11793] Add suggestion to error "undefined reference to `vtable for XXX'"
--- Additional Comments From drow at false dot org 2010-07-07 16:04 --- Subject: Re: Add suggestion to error "undefined reference to `vtable for XXX'" On Wed, Jul 07, 2010 at 03:50:32PM -, manu at gcc dot gnu dot org wrote: > I understand your frustration, but linker and compiler do not share a lot of > information and I think there is no way (right now) to give a good diagnostic > for this case. The linker does not know about vtables, pure functions and C++ > in > general. If there's an undefined reference to a vtable, what more does the linker need? --- Additional Comments From phresnel at gmail dot com 2010-07-07 21:37 --- (In reply to comment #3) > I understand your frustration, but linker and compiler do not share a lot of > information and I think there is no way (right now) to give a good diagnostic > for this case. The linker does not know about vtables, pure functions and C++ > in > general. I understand that there is not any C++ information available at that point of linking, but given the error message, it's prolly possible to look-up a suggestion somewhere, or even just extend the error message in question. > > I don't think that LLVM/Clang gives a better diagnostic here, because they > will > need a linker integrated tightly in the compiler, and (so far) they are using > the GNU linker. If you can show us otherwise, that would be great because I > really wish we could provide better diagnostics from the linker. I did not know this, interesting. -- http://sourceware.org/bugzilla/show_bug.cgi?id=11793 --- You are receiving this mail because: --- You are on the CC list for the bug, or are watching someone who is. ___ bug-binutils mailing list bug-binutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-binutils