AUTOSAR C++14 Rule A5-3-2
Description
Rule Definition
Null pointers shall not be dereferenced.
Rationale
Dereferencing a null pointer is undefined behavior. In most implementations, the dereference can cause your program to crash.
Polyspace Implementation
The checker flags pointer dereferences where the pointer might be NULL-valued.
If the issue occurs despite an earlier check for NULL
, look for
intermediate events between the check and the subsequent dereference. Often the result
details (or source code tooltips in Polyspace as You Code) show a sequence of events that
led to the defect. You can implement the fix on any event in the sequence. If the result
details do not show this event history, you can search for previous references of variables
relevant to the defect using right-click options in the source code and find related events.
See also Interpret Bug Finder Results in Polyspace Desktop User Interface or Interpret Bug Finder Results in Polyspace Access Web Interface (Polyspace Access).
Extend Checker
A default Bug Finder analysis might not raise a violation of this rule when the input values are unknown and only a subset of inputs can cause an issue. To check for violations caused by specific system input values, run a stricter Bug Finder analysis. See Extend Bug Finder Checkers to Find Defects from Specific System Input Values.
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: Expressions |
Category: Required, Partially automated |