cplusplus / cplusplus/draft

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

Open
#5,162 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TeX
Stars
221
Forks
813
Avg merge
16h 4m
Merged PRs (30d)
36

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with [dcl.init.aggr] p3.2 and the paragraph using “corresponding” in the aggregate-initialization wording. Compare their treatment of initializer-list elements and designated initializers, then clarify whether the wording should formally identify the nth element and its initializer.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
documentation
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.