Is modifying the internal bytes of a const object undefined behavior in case it contains another object constructed by placement new?
This is Undefined Behavior.
From [dcl.type.cv],
Any attempt to modify a const object during its lifetime results in undefined behavior.
Adding the mutable
specifier to buffer
will allow it to be modified by a const
member function.