Open cor3ntin opened 1 week ago
I started work on this
@llvm/issue-subscribers-clang-frontend
Author: cor3ntin (cor3ntin)
I'm not much of a spec person - does this include placing into an array of different type, e.g.:
char B[sizeof(int));
new (B) int{12};
?
Or is it only supposed to work if the types match, e.g.
int a;
new (&a) int{12};
I'm not much of a spec person - does this include placing into an array of different type, e.g.:
char B[sizeof(int)); new (B) int{12};
?
Or is it only supposed to work if the types match, e.g.
int a; new (&a) int{12};
I believe the former is not yet covered by P2747R2. Construction is still required to be performed on "properly typed" storage in constant evaluation.
The interconvertibility requirement allows things like
struct S {
int i;
};
S s;
new (&s) int(0);
because the pointer to s can be converted to a pointer to int (ie we have to chase various bases, subobjects and union members, but it is implementable.
(Without that restriction all existing c++ implementations would have to be thrown away afaik)
How can we choose a union member if multiple union members have the same type? That case hits angelic nondeterminism, which we can't really support here.
@zygoloid Haha, we were having that conversation at the same moment. Brian started a thread with CWG https://lists.isocpp.org/core/2024/07/16009.php (in part because the complexity introduced by interconvertibility may not be justified in the cases that would be implementable)
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p2747r2.html