AUTOSAR C++14 Rule M4-10-2
Literal zero (0) shall not be used as the null-pointer-constant
Description
Rule Definition
Literal zero (0) shall not be used as the null-pointer-constant.
Rationale
In C++, you can use the literals 0 and NULL as both an integer and a null pointer constant. However, use of 0 as a null pointer constant or NULL as an integer can cause developer confusion.
This rule restricts the use of the literal 0 to integers. AUTOSAR C++14 Rule M4-10-1
restricts the use of NULL to null pointer
constants.
Polyspace Implementation
The checker flags assignment of 0 to a pointer variable or binary operations involving 0 and a pointer. Assignments can be direct or indirect such as passing 0 as pointer argument to a function.
Troubleshooting
If you expect a rule violation but Polyspace® does not report it, see Diagnose Why Coding Standard Violations Do Not Appear as Expected.
Examples
Check Information
Group: Standard Conversions |
Category: Required, Automated |
Version History
Introduced in R2019a