https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128194
--- Comment #2 from Carlos Alberto Lopez Perez <clopez at igalia dot com> --- Fair enough. When I filed this I knew that the name is reserved, but I still thought GCC had a bug here, because the same code links fine without LTO, it also linked with LTO up to GCC 7.3, and when the link succeeds GCC handles the clash with a -Wodr warning instead of failing. Looking at it again, besides using a reserved name, the program also uses a variable that it never defines (the vtable isn't a definition of that array as far as C++ is concerned), so I agree this is undefined behaviour and that GCC doesn't need to support it. However, WebKit does this on purpose: it's a security check that compares an object's vtable pointer with the vtable of the expected class, and there's no standard way to get that address as far as I know, so it relies on how GCC and Clang name and lay out vtables (the Itanium C++ ABI). I will try to workaround it on the WebKit side at https://bugs.webkit.org/show_bug.cgi?id=329015 That said, the error message could be better. When the link fails, the only message is "missing resolution data for _ZTV7Derived", which looks like an internal error and doesn't point to the cause, while the -Wodr warning that GCC prints when the link succeeds (for example after removing unusedMake() from b.cpp) already names both the class and the conflicting declaration: vt.h:5:8: warning: virtual table of type 'struct Derived' violates one definition rule [-Wodr] 5 | struct Derived : Base { | ^ b.cpp:3:18: note: variable of same assembler name as the virtual table is defined in another translation unit 3 | extern "C" void* _ZTV7Derived[]; | ^ In a codebase the size of WebKit it took me a while to find what was triggering it. If the error could say something similar, that would be ideal; otherwise feel free to close this.
