In the following example:
Compiled with GCC 4.8 prints zero (same behavior with Clang 3.4). This seems to indicate that a initialized to zero before calling the default constructor.
But according to the value initialization rule on cppreference.com , an object should not be initialized before calling the default constructor. Class a is suitable for bullet point # 1 in C ++ 11:
1) If T is a class type with at least one user-supplied constructor of any type, the default constructor is called.
Another useful data point is that if we replace A() = default with A() {} in the above example, no zero-initialization does expected. This, apparently, indicates that in the original example the error No. 2 of initializing the value is executed, which would be incorrect:
2) If T is a type of non-unit class without any user-created constructors, then the object is initialized to zero, and then the implicitly declared default constructor is called (unless it is trivial)
source share