Description
Full name of submitter (unless configured in github; will be published with the issue): Jiang An
Reference (section label): [expr.new], [basic.life]
Link to reflector thread (if any):
Issue description:
It seems that nothing in [expr.new] says that non-allocating placement new at an unaligned address has undefined behavior. [basic.life] p1.1 may be related, but one may think that such a new-expression just fails to create an object while being well-defined (however, the value of the new-expression seems underspecified if so).
For example, assuming alignof(double) == 8
.
#include <new>
int main() {
alignas(double) unsigned char buf[sizeof(double) + 1];
new ((void*)(buf + 1)) double{};
}
Does the above program have undefined behavior? Or is the behavior well-defined despite that the new-expression doesn't create a double
object?
It seems that the behavior should be undefined, because it generally requests unaligned access.
Suggested resolution: