You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the generated C++ side of the UniquePtr impl currently contains something like the following as the implementation backing UniquePtr::new and UniquePtr::drop:
This is Bad because in the case that ::Type has a class-specific member operator new and operator delete, we'd allocate without using its operator new and delete with its operator delete, which is UB.
For an input like this:
the generated C++ side of the UniquePtr impl currently contains something like the following as the implementation backing UniquePtr::new and UniquePtr::drop:
This is Bad because in the case that ::Type has a class-specific member
operator new
andoperator delete
, we'd allocate without using itsoperator new
and delete with itsoperator delete
, which is UB.Relevant to e.g.
std::unique_ptr<folly::IOBuf>
: https://github.com/facebook/folly/blob/cd39f451c749ff502cf5e062ab094762d1806f00/folly/io/IOBuf.h#L1314-L1323Fix is to SFINAE detect a class-specific member
operator new
on MaybeUninit'sT
and apply that during the MaybeUninit allocation.Demo showing the correct in-place construction and destruction sequence:
The text was updated successfully, but these errors were encountered: