Talk:cpp/language/default initialization

Misleading example
I found the example a bit misleading, because by pointing out that T2::mem get initialized to an indeterminate value, it creates the impression (for me anyway) that the implicitly generated default constructor for T1 would actually initialize mem to 0.

But when examining the text carefully I see that the generated default constructor for T1 will behave as the one defined for T2, so even T1::mem has will have an indeterminate value.

141.143.213.40 07:56, 24 October 2018 (PDT)

Static and thread-local variables of non-class type are not mentioned in "Effects" section
Static and thread-local variables of non-class type are not mentioned in "Effects" section. I would add one more point after second one:


 * if T is a class type .....
 * if T is an array type .....
 * if T is non-class type with static or thread-local storage duration, it is zero-initialized;
 * otherwise, nothing is done .....

Also I would add dynamic storage duration to the last point.

Then first sentence in Notes section could be removed. -- Valiko (talk) 02:18, 19 October 2019 (PDT)


 * it's because this follows the spec where zero-init comes first, and default init on top of that "does nothing"... I think extending the "Nothing is done" line would make this work better here: we already extend it with details on what happens to objects with automatic storage duration. It could simply mention other durations right there. --Cubbi (talk) 07:19, 21 October 2019 (PDT)


 * Makes sense. Current text is a bit confusing until you read the Notes section. -- Valiko (talk) 11:09, 22 October 2019 (PDT)