Isn't this value initialization??
On my machine, your program outputs -1219700747HelloWorld244
, a clear indicator for default initialisation.
That you get 0HelloWorld0
isn't fully random and can have many reasons. For example, it has something to do with your os architecture. All new memory for each program is initially zeroed, and this is why in this simple example, everything is set to zero. Or the compiler initializes the struct statically for performance reasons.
To quote the standard at 12.6.2/8:
In a non-delegating constructor, if a given non-static data member or base class is not designated by a
mem-initializer-id (including the case where there is no mem-initializer-list because the constructor has no
ctor-initializer) and the entity is not a virtual base class of an abstract class (10.4), then
— if the entity is a non-static data member that has a brace-or-equal-initializer, the entity is initialized
as specified in 8.5;
— otherwise, if the entity is an anonymous union or a variant member (9.5), no initialization is performed;
— otherwise, the entity is default-initialized (8.5).