Literal zero (0) shall not be used as the null-pointer-constant
Literal zero (0) shall not be used as the null-pointer-constant.
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. MISRA C++:2008 Rule 4-10-1 restricts
the use of NULL to null pointer constants.
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.
If you expect a rule violation but do not see it, refer to the documentation for Polyspace® Bug Finder™ or Polyspace Bug Finder Server™.
| Group: Standard Conversions |
| Category: Required |