AUTOSAR C++14 Rule A0-4-4
Range, domain and pole errors shall be checked when using math functions
Since R2022a
Description
Rule Definition
Range, domain and pole errors shall be checked when using math functions.
Rationale
Before using a math function, check input arguments for potential domain, range, and pole errors.
This checker searches for domain errors when a function argument falls outside the allowed domain, pole errors when finite arguments result in infinite results, and range errors when results of a function cannot be represented by the return value limitations.
Domain, pole and range errors result in unexpected or undefined behavior.
Polyspace Implementation
Polyspace® raises this defect when you call a math function that results in a domain, pole, or range error.
By default, a Bug Finder analysis does not recognize infinities and
NaNs
. Operations that results in infinities and NaNs
might be flagged as defects. To handle infinities and NaN
values in your
code, use the option Consider non finite floats
(-allow-non-finite-floats)
.
Extend Checker
Extend this checker to check for defects caused by specific values and invalid use of functions from a custom library. For instance:
You might be using a custom library of mathematical functions. If a custom library function have the same domain and range as another function from the standard library, you can extend this checker to check the custom library function. See Extend Bug Finder Checkers for Standard Library Functions to Custom Libraries.
A default Bug Finder analysis might not raise a defect when the input values are unknown and only a subset of inputs can cause an issue. To check for defects 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: Language independent issues |
Category: Required, Partially automated |
Version History
Introduced in R2022a