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

[expr.new] Is a copy constructor call elided in a new-expression? #2484

Closed
jensmaurer opened this issue Nov 16, 2018 · 0 comments
Closed

[expr.new] Is a copy constructor call elided in a new-expression? #2484

jensmaurer opened this issue Nov 16, 2018 · 0 comments
Assignees

Comments

@jensmaurer
Copy link
Member

jensmaurer commented Nov 16, 2018

[expr.new] p19.2 makes it clear that we perform direct-initialization, which means the copy constructor of T is not called in a case like this:

struct T { };
T f();
T * p = new T(f());

However, p21 then talks about "the constructor" in the class object case, which could lead to the misunderstanding that some constructor is always called. This is amplified because allocation/deallocation functions are mentioned in the same sentence, and accessibility to those is always checked, even if the allocation is elided.
Suggestion: add "(if any)" after "the constructor". (The "no constructor" case also arises for aggregate initialization, it seems.)
Do we have a good cross-reference target when we want to talk about "mandatory copy elision"?

@jensmaurer jensmaurer changed the title [expr.new] Can the constructor call be elided in a new-expression? [expr.new] Is a copy constructor call elided in a new-expression? Nov 16, 2018
@jensmaurer jensmaurer self-assigned this Dec 20, 2018
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