This code:
class A {
public:
A() = default;
};
int main()
{
const A a;
return 0;
}
can be compiled without errors in Visual C++ (from VS 2015 Update 2) and GCC (5.3.1), but can not be compiled with Clang, it gives this error:
test.cpp:8:13: error: default initialization of an object of const type
'const A' without a user-provided default constructor
const A a;
^
{}
1 error generated.
Who is right, clang or gcc and MSVC? Are other compilers behavior is a bug?
PS. const A a{};
is compiled without errors with all three.
Same if we define empty constructor: A::A() {}
.
PPS. This is NOT a duplicate. I emphasize the actual question.
Update Filed a bug in MSVC: https://connect.microsoft.com/VisualStudio/feedback/details/2538005 S.T.L. said that they are in process of fixing them all to conform clang tests: https://twitter.com/StephanTLavavej/status/715923311796953089