I cannot understand the behavior of gcc 4.8.1 or Visual Studio 2015 with respect to default initialization versus value initialization.
It doesn\'t help that I\'m tr
Foo foo;
This default-initializes foo
, and since Foo
's default constructor is trivial, it effectively doesn't initialize it at all, so foo._bar
can hold any value (including 0).
Foo()
This value-initializes the temporary object, which in case of trivial default constructor means zero-initialization, so Foo()._bar
is equal to 0.