Qt-Autosar-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
| Level | required |
|---|---|
| Target | implementation |
| Enforcement | automated |
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¶
This rule shares the following common options: confidence, exclude_in_macros, exclude_messages_in_system_headers, excludes, extend_exclude_to_macro_invocations, includes, justification_checker, languages, post_processing, provider, report_at, severity
The following places define options that affect this rule: Stylechecks, Analysis-GlobalOptions
enforce_corresponding_parameters¶
enforce_corresponding_parameters : bool = False
enforce_same_file¶
enforce_same_file : bool = False