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

--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The C++17 draft requires aligned-delete to be used for memory obtained from
aligned-new (and not otherwise):

"Requires: If the alignment parameter is not present, ptr shall have been
returned by an allocation function without an alignment parameter. If present,
the alignment argument shall equal the alignment argument passed to the
allocation function that returned ptr."

So for aligned-new we can over-allocate and return a suitably aligned pointer
within the allocated region, storing a cookie before that pointer that tells us
the address originally obtained from malloc. For aligned-delete we read the
cookie.

Reply via email to