メインコンテンツ

-detect-bad-float-op-on-zero

Detect floating point comparison with equality operator when one of the operand is 0.0

Syntax

-detect-bad-float-op-on-zero

Description

-detect-bad-float-op-on-zero modifies the behavior of Polyspace® Bug Finder™ checkers so that equality comparison using an equality (==) or inequality (!=) operator is reported even when one of the operand is 0.0.

Examples

Consider this code:

extern float foo(void);
float x;
x = foo();
if (x==0.0f) {
//...
}
By default, Polyspace Bug Finder does not report a defect or violation on the operation (x==0.0f). If you specify this option, then these violations and defects are reported for the comparison operation:

If you are running an analysis from the Polyspace Platform user interface, you can apply this option through the project configuration. To do so, navigate to the Static Analysis tab, select the Advanced node, and enter -detect-bad-float-op-on-zero in the Other field. See Other. To specify this option at the command line, append the option to your usual Bug Finder command:

polyspace-bug-finder -sources filename ^
-checkers BAD_FLOAT_OP -detect-bad-float-op-on-zero