C++

Your buffer is not a struct yet -- Mateusz Pusz

In the third part of his series on C++ rules that experienced developers get wrong, Mateusz Pusz examines when casting a byte buffer to a struct is undefined behavior. The answer depends on whether the type is implicit-lifetime and whether an operation such as a std::byte array, operator new, std::malloc, std::memcpy or std::bit_cast implicitly created the object. Otherwise he recommends C++23's std::start_lifetime_as, placement new or std::construct_at.

AI-written summary, checked against the cited sources. How summaries work

Read at isocpp.org