This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 112c. See for the official list.


2744. Multiple objects of the same type at the same address

Section: 6.7.2  [intro.object]     Status: open     Submitter: Chris Hallock     Date: 2023-06-08

(From thread beginning here.)


  #include <new>

  struct A { unsigned char buf[1]; };
  static_assert(sizeof(A) == 1); // A can fit within A::buf

  int main()
    A x{};
    new (x.buf) A{};

A::buf provides storage for another A object. Thus, there are now two objects of type A within lifetime, which is inconsistent with the goal expressed by 6.7.2 [intro.object] paragraph 9.

Suggested resolution:

Change in 6.7.2 [intro.object] paragraph 3 as follows:

If a complete object of type T is created ( []) in storage associated with another object e of type “array of N unsigned char” or of type “array of N std::byte” (17.2.1 [cstddef.syn]), that array provides storage for the created object if: