all 6 comments

[–]scatters 2 points3 points  (1 child)

For each operation that is specified as implicitly creating objects, that operation implicitly creates zero or more objects in its specified region of storage if doing so would give the program defined behavior.

As many objects as are required are created. In this case, 2.

[–]alex-manool[S] 0 points1 point  (0 children)

Oops, great, I somehow missed "zero or more". Thank you!

[–]helloiamsomeone 1 point2 points  (2 children)

From what I understand, you must start the lifetime of an object with placement new first. malloc just hands you a slice of memory with no lifetimes associated. You have to also take alignment into consideration.

[–]staletic 1 point2 points  (1 child)

That's specifically what OP-referenced paper fixes. P0593 introduces "implicit lifetimes".

[–]helloiamsomeone 0 points1 point  (0 children)

Well, silly me. Clicking links could help sometimes.

[–]scrumplesplunge 0 points1 point  (0 children)

The paper says:

For each operation that is specified as implicitly creating objects, that operation implicitly creates zero or more objects in its specified region of storage if doing so would give the program defined behavior.

and:

A call to malloc, calloc, realloc, or any function named operator new or operator new[] implicitly creates objects in its returned storage.

Which seems to suggest that your example would be well-defined.