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

--- Comment #2 from Francisco Paisana <paisanafc at gmail dot com> ---
Jonathan Wakely, thanks a lot for your clarification. I finally got it. 

In summary, we established that:
1. if a type T (in my case C) has no user-defined ctor, it will be
zero-initialized.
2. and for that T, "each non-static data member ... is zero-initialized."

For others that might fall into the same trap as me, the important detail in 2
is that members are "zero-initialized" and not "value-initialized". If
non-static data members were value-initialized (not the case!), then my
original comment would have been true based on the clause (see
https://en.cppreference.com/w/cpp/language/zero_initialization):

"Zero-initialization is performed in the following situations:
...
2) As part of value-initialization sequence [...] for members of
value-initialized class types that have no constructors."

I wonder if there is a way to forbid the members of a class type from ever
being zero-initialized in C++.

In any case, we can mark this issue as solved.

Reply via email to