Skip to content
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

[dcl.init.aggr] The meaning of "corresponding" is vague in aggregate initialization #5162

Open
xmh0511 opened this issue Dec 22, 2021 · 0 comments

Comments

@xmh0511
Copy link
Contributor

xmh0511 commented Dec 22, 2021

Since in c++17 standard, we introduce the aggregate initialization with the following sentence

When an aggregate is initialized by an initializer list as specified in [dcl.init.list], the elements of the initializer list are taken as initializers for the elements of the aggregate, in order.

"In order" hints that each element is initialized with the subsequent element of the initializer list. "In order" is instead with "corresponding" in the current draft, such as

Otherwise, the element is copy-initialized from the corresponding initializer-clause or is initialized with the brace-or-equal-initializer of the corresponding designated-initializer-clause.

I would argue that the use of either "in order" or "corresponding" is a bit vague in the definitions of the aggregate initialization. We should give that definition a more formal approach? For instance

Otherwise, the nth element is copy-initialized from the corresponding nth initializer-clause or is initialized with the brace-or-equal-initializer of the corresponding nth designated-initializer-clause.

Which can coordinate with [dcl.init.aggr] p3.2

If the initializer list is a brace-enclosed initializer-list, the explicitly initialized elements of the aggregate are the first n elements of the aggregate, where n is the number of elements in the initializer list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant