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]/7.1 Use of "initializer ()" #2846

Open
randomnetcat opened this issue Apr 27, 2019 · 2 comments
Open

[dcl.init]/7.1 Use of "initializer ()" #2846

randomnetcat opened this issue Apr 27, 2019 · 2 comments
Labels
cwg Issue must be reviewed by CWG.

Comments

@randomnetcat
Copy link
Contributor

[dcl.init]/7.1 says:

To default-initialize an object of type T means:

  • If T is a (possibly cv-qualified) class type ([class]), constructors are considered. The applicable constructors are enumerated ([over.match.ctor]), and the best one for the initializer () is chosen through overload resolution ([over.match]). The constructor thus selected is called, with an empty argument list, to initialize the object.

This usage requires that () be a valid value for the grammar term initializer. This is not the case according to the initializer definition:

initializer:

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

expression-list cannot be empty, so () is not a valid initializer.

@zygoloid
Copy link
Member

This has been wrong since C++98. I think the best resolution would be to add [opt] after expression-list here, and rely on normal disambiguation rules to treat int x() as a function declaration. But I think this should be handled by CWG.

@jensmaurer
Copy link
Member

Submitted to CWG: http://lists.isocpp.org/core/2019/05/6127.php

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cwg Issue must be reviewed by CWG.
Projects
None yet
Development

No branches or pull requests

3 participants