Overflow
Arithmetic operation causes overflow
Description
This check on an arithmetic operation determines whether the result overflows. The result of this check depends on whether you allow nonfinite float results such as infinity and NaN.
The result of the check also depends on the float rounding mode you specify. By default, the
rounding mode is to-nearest
. See Float rounding mode (-float-rounding-mode)
.
Nonfinite Floats Not Allowed
By default, nonfinite floats are not allowed. When the result of an operation falls outside the allowed range, an overflow occurs. The check is:
Red, if the result of the operation falls outside the allowed range.
Orange, if the result of the operation falls outside the allowed range on some of the execution paths.
Green, if the result of the operation does not fall outside the allowed range.
To fine tune the behavior of the overflow check, use these options and
specify argument forbid
, allow
, or
warn-with-wrap-around
:
The operand data types determine the allowed range for the arithmetic operation. If the operation involves two operands, the verification uses the ANSI® C conversion rules to determine a common data type. This common data type determines the allowed range.
For some examples of conversion rules, see Code Prover Assumptions About Implicit Data Type Conversions.
Nonfinite Floats Allowed
If you enable a verification mode that incorporates infinities and specify that the verification must warn about operations that produce infinities, the check is:
Red, if the operation produces infinity on all execution paths that the software considers, and the operands themselves are not infinite.
Orange, if the operation produces infinity on some of the execution paths when the operands themselves are not infinite.
Green, if the operation does not produce infinity unless the operands themselves are infinite.
If you specify that the verification must forbid operations that produce infinities, the check color depends on the result of the operation only. The color does not depend on the operands.
To enable this verification mode, use these options:
Infinities (-check-infinite)
: Use argumentwarn
orforbid
.
Diagnosing This Check
Examples
Check Information
Group: Numerical |
Language: C | C++ |
Acronym: OVFL |