-
Notifications
You must be signed in to change notification settings - Fork 1
CWG2536 Zero-initialization in addition to constant initialization and stability of padding bits #1380
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Note that the restriction explicitly dropped in P1331R2 was one that prevented the constructor from leaving subobjects uninitialized during evaluation of a core constant expression. It happens so that is was also the restriction that (aside from pointer types) prevented uninitialized subobjects from being part of the result of a constant expression. A related question arises from the resolution of CWG2424, " Also note that the question of CWG2536 does not arise from the wording out of the case presented if the resolution to CWG2558 is that uninitialized subobjects cannot be part of the result of a constant expression. However, the question would then be whether there is a desire to prohibit dynamic initialization for the case presented by applying zero initialization before or after the fact (including to temporaries bound to references). The additional questions for a before-the-fact application of zero initialization is also the topic of CWG2301, "Value-initialization and constexpr constructor evaluation". Note that the status quo also allows constant-initialized variables of static storage duration to be statically initialized such that there is uninitialized padding. Edits:
|
This was discussed at the Jan, 19, 2023 CWG Issues Review And the following polls were taken:
Result: Strong Consensus Union types shall be initialized such that they have an active member in the result of a constant expression.
Result: Not Consensus EWG confirms that padding bits and data belonging to non-active variant members are permitted to have indeterminate values in the static initialization of objects.
Result: Not Consensus |
@erichkeane , it seems to me that CWG2558 (Is it intentional that uninitialized subobjects can appear in prvalues returned by constant expressions?) was answered, and CWG will proceed to restrict constant expression results so that they contain no uninitialized members. However, CWG2536 and the question whether zero-initialization of static and thread storage duration variables happens in addition to constant initialization and whether the padding bits that got zeroed that way have a stable value is unanswered, and still the subject of ongoing discussions on -ext. I've changed the subject of this issue accordingly and I'm giving this issue back to EWG. |
This was discussed briefly in the February 6th, 2023 Afternoon session in Issaquah. No polls were taken, as the room didn't feel comfortable with our understanding of the issue. We either need a paper, or to re-visit this with a CWG representative (@hubert-reinterpretcast ?). |
See CWG2558 and CWG2536
CWG2558: Is it intentional that uninitialized subobjects can appear in prvalues returned by constant expressions?
P1331R2 dropped the corresponding restriction, but maybe that wasn't entirely intentional.
CWG2536: The variable
a
is a variable with static storage duration, which previously could not have subobjects with indeterminate value (because of zero-initialization). The status quo wording does permit such indeterminate values. Is that intentional?The text was updated successfully, but these errors were encountered: