https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111771

--- Comment #2 from Egor <iamsupermouse at mail dot ru> ---
Before calling A's constructor, it will zero `x` anyway.

I was also surprised when I learned this yesterday, but it's what the standard
says.

1. `()` performs value-initialization on B:
http://eel.is/c++draft/dcl.dcl#dcl.init.general-16.4

2. Since B's ctor is not user-provided, that resolves to zero-initialization
followed by default-initialization:
http://eel.is/c++draft/dcl.dcl#dcl.init.general-9.1.2

3. Zero-initialization of B propagates to A, then propagates to `x` and zeroes
it, regardless of A having a user-provided constructor or not:
http://eel.is/c++draft/dcl.dcl#dcl.init.general-6.2

4. Lastly default-initialization of B calls B's constructor and in turn calls
A's constructor.

Reply via email to