cplusplus / cplusplus/draft

[over.match.ctor] Initialization by "()" does not match "initializer" grammar term

Open
#2,847 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

[over.match.ctor] says:

When objects of class type are direct-initialized, copy-initialized from an expression of the same or a derived class type ([dcl.init]), or default-initialized, overload resolution selects the constructor. For direct-initialization or default-initialization that is not in the context of copy-initialization, the candidate functions are all the constructors of the class of the object being initialized. For copy-initialization (including default initialization in the context of copy-initialization), the candidate functions are all the converting constructors ([class.conv.ctor]) of that class. The argument list is the expression-list or assignment-expression of the initializer.

Default-initialization invokes this clause with "the initializer ()" (see #2846) for class types. This clause has a similar issue.

The sentence "The argument list is the expression-list or assignment-expression of the initializer" uses the initializer grammar term:

initializer:

  • brace-or-equal-initializer
  • ( expression-list )

This does not accept ().

Thus, this clause has no ability to handle invoking a default constructor, such as default-initialization intends to invoke for class types.

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

Locate the [over.match.ctor] clause in the draft source and read its description of the argument list alongside the initializer grammar term. Check how the wording handles default-initialization with () and confirm that invoking a default constructor is represented consistently. Done means the clause accepts this form without contradicting the grammar or the related issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, tex
Domain
compilers, documentation
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.