Skip to content

Rules for array cookies are outdated #119

@jwakely

Description

@jwakely

https://itanium-cxx-abi.github.io/cxx-abi/abi.html#array-cookies says:

cxx-abi/abi.html

Lines 2123 to 2127 in 7f36ec6

<li> No cookie is required if the array element type T has a trivial
destructor (12.4 [class.dtor])
and the usual (array) deallocation function
(3.7.3.2 [basic.stc.dynamic.deallocation])
function does not take two arguments.

This is wrong since C++17, because T::operator new[](std::size_t, std::align_val_t) has two parameters, but still needs a cookie unless T has a trivial destructor. It might also be wrong for a C++20 destroying operator delete, but I haven't spent enough time thinking about that case.

The note is also outdated:

cxx-abi/abi.html

Lines 2130 to 2134 in 7f36ec6

(Note: if the usual array deallocation function takes two arguments,
then it is a member function whose second argument is of type size_t.
The standard guarantees (12.5 [class.free])
that this function will be passed the
number of bytes allocated with the previous array new expression.)

Since C++14 added sized deallocation there is a usual deallocation functions with two parameters that isn't a member function, operator delete[](void*, std::size_t).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions