You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
(In N4820) The first example says that
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 variablea
ing
whose lifetime has ended.The text was updated successfully, but these errors were encountered: