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

The bound of considering the context of the copy-initialization #5490

Open
xmh0511 opened this issue May 24, 2022 · 0 comments
Open

The bound of considering the context of the copy-initialization #5490

xmh0511 opened this issue May 24, 2022 · 0 comments

Comments

@xmh0511
Copy link
Contributor

xmh0511 commented May 24, 2022

[dcl.init.general] p14 says

The initialization that occurs in the = form of a brace-or-equal-initializer or condition ([stmt.select]), as well as in argument passing, function return, throwing an exception ([except.throw]), handling an exception ([except.handle]), and aggregate member initialization ([dcl.init.aggr]), is called copy-initialization.

Consider this example:

struct T{
    explicit T(){}
};
T v = T();

The initialization occurs in the = form of a brace-or-equal-initializer, even though we have specified that the result object is direct-initialized by (). So the initialization is in the context of the copy-initialization? The explicit default constructor won't be considered for the default-initialization, according to [over.match.ctor] p1

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.

Presumably, It is not the intent of these rules. [dcl.init.general] p14 just contradicts the initialization specified for prvalue(e.g. which wants that the context is a direct-initialization).

This issue might relate to #4582. We should remove [dcl.init.general] p14. What kind of initialization(i.e. copy or direct-initialization) should be decided/specified by the concrete rules.

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