Suppose we have this code:
class A
{
public:
A()=default;
A(const A &)=delete;
~A()=default;
};
class B
{
public:
B() : a{}
{}
A a[1];
};
int main()
{
B b;
}
This code compiles on latest gcc9.2, clang9.2, mvsc19.22.
But when I change A default c-tor to ~A(){} gcc returns error use of deleted function 'A::A(const A&)'. Clang and MSVC still compiles.
When I write copy c-tor to A gcc compiles, but in runtime this c-tor was never called. What gcc need copy c-tor for? Is it gcc bug (I`ve tried about all gcc versions on GodBolt.org - same error)?
Aucun commentaire:
Enregistrer un commentaire