Annex F (informative) Core undefined behavior [ub]

F.2 [basic]: Basics [ub.basic]

F.2.2[ub:intro.object.implicit.pointer]
Specified in: [intro.object]

After implicitly creating objects within a specified region of storage, some operations are described as producing a pointer to a suitable created object ([basic.types]).
These operations select one of the implicitly-created objects whose address is the address of the start of the region of storage, and produce a pointer value that points to that object, if that value would result in the program having defined behavior.
If no such pointer value would give the program defined behavior, the behavior of the program is undefined.
[Example 1: #include <cstdlib> struct X { int a, b; ~X() = delete; // deleted destructor makes X a non-implicit-lifetime class }; X* make_x() { X* p = (X*)std::malloc(sizeof(struct X)); // Cannot implicitly create an object because X // is not an implicit-lifetime class. p->a = 1; // undefined behavior, no set of objects give us defined behavior return p; } — end example]
[Example 2: #include <cstdlib> struct X { int a; }; struct Y { int x; }; Y* make_y() { X* p1 = (X*)std::malloc(sizeof(struct X)); // object #1 p1->a = 1; Y* p2 = (Y*)p1; p2->x = 2; // undefined behavior, p2 points to an in-lifetime object of type X, // which is not similar to Y ([expr.ref]) return p2; } — end example]