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

[class.copy.elision] Is the first example contradictory? #3117

Closed
frederick-vs-ja opened this issue Aug 2, 2019 · 1 comment · Fixed by #3254
Closed

[class.copy.elision] Is the first example contradictory? #3117

frederick-vs-ja opened this issue Aug 2, 2019 · 1 comment · Fixed by #3254
Assignees

Comments

@frederick-vs-ja
Copy link
Contributor

(In N4820) The first example says that

struct A {
  void *p;
  constexpr A(): p(this) {}
};

constexpr A g() {
  A a;
  return a;
}

constexpr A a;          // well-formed, a.p points to a
constexpr A b = g();    // well-formed, b.p points to b

However, if my understanding is correct, as copy elision (NRVO) is forbidden in constant initialization since CWG 2278, b.p shall point to the local variable a in g whose lifetime has ended.

@jensmaurer jensmaurer added the decision-required A decision of the editorial group (or the Project Editor) is required. label Aug 6, 2019
@jensmaurer jensmaurer added decision-required A decision of the editorial group (or the Project Editor) is required. and removed decision-required A decision of the editorial group (or the Project Editor) is required. labels Sep 10, 2019
@jensmaurer jensmaurer removed the decision-required A decision of the editorial group (or the Project Editor) is required. label Sep 30, 2019
@jensmaurer
Copy link
Member

Editorial teleconference: Agreed, this is an error in second line of the example. Also change name of local variable "a" to avoid duplication of name.

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

Successfully merging a pull request may close this issue.

2 participants