public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/105442] New: [modules] exporting a class with an inline virtual destructor causes linker errors (duplicate symbols)
@ 2022-04-30 17:22 john at johnmaddock dot co.uk
0 siblings, 0 replies; only message in thread
From: john at johnmaddock dot co.uk @ 2022-04-30 17:22 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105442
Bug ID: 105442
Summary: [modules] exporting a class with an inline virtual
destructor causes linker errors (duplicate symbols)
Product: gcc
Version: 11.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: john at johnmaddock dot co.uk
Target Milestone: ---
Found while experimenting with modules for Boost.Math, consider a module which
exports an exception type:
module;
#include <stdexcept>
export module virtual_destructor_test;
export class evaluation_error : public std::runtime_error
{
public:
evaluation_error(const std::string& s) : std::runtime_error(s) {}
inline ~evaluation_error() {}
};
And a trivial program which uses it:
#include <string>
import virtual_destructor_test;
int main()
{
evaluation_error eval(std::string("test me"));
}
Then I see:
D:/compilers/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe:
D:\compilers\msys64\tmp\cch2gAHF.o:virtual_test.c:(.text+0x0): multiple
definition of `evaluation_error::~evaluation_error()';
D:\compilers\msys64\tmp\cc35c6Fy.o:virtual.cxx:(.text$_ZN16evaluation_errorD1Ev[_ZN16evaluation_errorD1Ev]+0x0):
first defined here
D:/compilers/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe:
D:\compilers\msys64\tmp\cch2gAHF.o:virtual_test.c:(.text+0x2e): multiple
definition of `evaluation_error::~evaluation_error()';
D:\compilers\msys64\tmp\cc35c6Fy.o:virtual.cxx:(.text$_ZN16evaluation_errorD0Ev[_ZN16evaluation_errorD0Ev]+0x0):
first defined here
D:/compilers/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe:
D:\compilers\msys64\tmp\cch2gAHF.o:virtual_test.c:(.rdata+0x50): multiple
definition of `vtable for evaluation_error';
D:\compilers\msys64\tmp\cc35c6Fy.o:virtual.cxx:(.rdata$_ZTV16evaluation_error[_ZTV16evaluation_error]+0x0):
first defined here
The issue occurs if:
* No destructor is declared.
* The destructor is = default;
* The destructor is inline.
It does NOT occur if the destructor is declared non-inline.
Looks like the compiler should assume that vtables are always in the module?
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-04-30 17:22 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-30 17:22 [Bug c++/105442] New: [modules] exporting a class with an inline virtual destructor causes linker errors (duplicate symbols) john at johnmaddock dot co.uk
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).