https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125151
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
In the end, I think with -std=c++26 you basically get something like
struct A {
constexpr A () noexcept {}
constexpr virtual ~A () noexcept {}
constexpr A (const A &) = default;
constexpr A &operator= (const A &) = default;
constexpr A (A &&) = default;
constexpr A &operator= (A &&) = default;
constexpr virtual const char *what () { return "A"; }
};
struct B : A {
constexpr B (int x) : b (x) {}
constexpr virtual ~B () noexcept {}
constexpr B (const B &) = default;
constexpr B &operator= (const B &) = default;
constexpr B (B &&) = default;
constexpr B &operator= (B &&) = default;
constexpr virtual const char *what () { return "B"; }
int b;
};
int
main ()
{
B c (42);
B d = c;
}
where A is roughly std::exception and B roughly std::runtime_exception
(simplified to use just int instead of std::string).
Do you say the defaulted copy ctor is not linkonce on mingw?
Or is the problem just that it is linkonce in all the defaulted definitions (so
you could link with -O0 -std=c++26 above source and one with s/main/foo/) and
just that the definition in src/c++98/stdexcept.cc is not linkonce and the
linker diagnoses such case ?
Note, compiler warns and ignores on [[gnu::weak]] on inline functions (which
includes the defaulted constexpr methods). Would [[gnu::weak]] on the
stdexcept.cc symbol fix that?