[Bug c++/104918] New: Pass information to let the linker tell the user which virtual members are missing
eyalroz1 at gmx dot com
gcc-bugzilla@gcc.gnu.org
Mon Mar 14 13:59:22 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104918
Bug ID: 104918
Summary: Pass information to let the linker tell the user which
virtual members are missing
Product: gcc
Version: 11.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: eyalroz1 at gmx dot com
Target Milestone: ---
Consider the following program:
```
struct A {
virtual void foo() { }
};
struct B : A {
void foo() override;
};
int main() {
B b;
}
```
this compiles, but fails to link: https://godbolt.org/z/Mzx3c7354
```
<source>:10: undefined reference to `vtable for B'
```
which is fine, but - I'm annoyed the linker doesn't tell me which virtual
member is missing. That might be an issue with the linker, but - is foo even a
symbol in the compiled code? I tried compiling this into an object file and
using objdump (on my GNU/Linux Devuan Chimaera), and got:
a.o: file format elf64-x86-64
SYMBOL TABLE:
0000000000000000 l df *ABS* 0000000000000000 a.cpp
0000000000000000 l d .text 0000000000000000 .text
0000000000000000 l d .data 0000000000000000 .data
0000000000000000 l d .bss 0000000000000000 .bss
0000000000000000 l d .note.GNU-stack 0000000000000000
.note.GNU-stack
0000000000000000 l d .eh_frame 0000000000000000 .eh_frame
0000000000000000 l d .comment 0000000000000000 .comment
0000000000000000 g F .text 0000000000000016 main
0000000000000000 *UND* 0000000000000000 vtable for B
So, no foo... and no way for the linker to be able to tell me what's missing.
I claim that GCC should expose information via the symbol table (or otherwise?)
that would let ld tell me which virtual member it's missing.
More information about the Gcc-bugs
mailing list