AutosarC++19_03-M4.10.2

Literal zero (0) shall not be used as the null-pointer-constant

Required inputs: IR

Using literal zero (0) as a null pointer constant is ambiguous: it could be read as the integer zero or as a pointer. The macro NULL or C++11 nullptr makes the intent explicit and prevents confusion. Code using proper null pointer constants is clearer and less error-prone.
Bad code (literal zero as null):
int* ptr = 0;          // ERROR: ambiguous - is this int zero or null pointer?
if (ptr == 0) { }      // Unclear intent
Good code (using NULL macro):
int* ptr = NULL;       // OK: explicit null pointer constant
if (ptr == NULL) { }   // Clear intent
Good code (using C++11 nullptr):
int* ptr = nullptr;    // OK: type-safe null pointer
if (ptr == nullptr) {} // Clear and type-safe

Note

For legal reasons, this rule’s description is not part of the public documentation.