https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113258

--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Nicholas Miell from comment #0)
> This is typically the result of the libstdc++ version of operator
> delete(void* ptr, std::align_val_t alignment) calling the
> application-supplied version of operator delete(void* ptr),

But it doesn't do that.

The libstdc++ version of operator delete(void*, size_t, align_val_t) calls
std::free directly, because that's the correct way to free memory obtained by
the libstdc++ version of the operator new(size_t, align_val_t).

If you are allocating memory with operator new(size_t, std::align_val_t) and
then seeing a crash when it's deallocated with operator delete(void*) that is a
bug in the application. Memory allocated by aligned-new must be deallocated by
aligned-delete, see [new.delete.single] p11:

If the alignment parameter is not present, ptr was returned by an allocation
function without an alignment parameter. If present, the alignment argument is
equal to the alignment argument passed to the allocation function that returned
ptr. If present, the size argument is equal to the size argument passed to the
allocation function that returned ptr.

Reply via email to