AutosarC++18_10-A18.5.4

If a project has sized or unsized version of operator “delete” globally defined, then both sized and unsized versions shall be defined

Required inputs: IR

Rationale

Since C++14 Language Standard it is allowed to overload both sized and unsized versions of the “delete” operator. Sized version provides more efficient way of memory deallocation than the unsized one, especially when the allocator allocates in size categories instead of storing the size nearby the object.

Example
//% $Id: A18-5-4.cpp 289415 2017-10-04 09:10:20Z piotr.serwa $
    #include <cstdlib>
    void operator delete(
        void* ptr) noexcept // Compliant - sized version is defined
    {
        std::free(ptr);
    }
    void operator delete(
        void* ptr,
        std::size_t size) noexcept // Compliant - unsized version is defined
    {
        std::free(ptr);
    }
See Also
  • none

Possible Messages

Key

Text

Severity

Disabled

only_sized

Only the sized version of operator delete is defined.

None

False

only_unsized

Only the unsized version of operator delete is defined.

None

False

Options

enforce_corresponding_parameters

enforce_corresponding_parameters : bool = False

If the analysis should enforce that both sized and unsized operators have corresponding parameters (except for size_t).
 

enforce_same_file

enforce_same_file : bool = False

If the analysis should enforce that both sized and unsized operators are in the same file.