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 GCC 9.2, Clang 9.2, and MSVC 19.22.
But when I change A default destructor to ~A() { }
GCC returns error use of deleted function 'A::A(const A&)'
. Clang and MSVC still compile.
When I write the copy constructor of A
, GCC compiles, but at runtime this constructor was never called. What does GCC need the copy constructor for?
Is it GCC bug? (I've tried about all GCC versions on GodBolt.org, same error.)