Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Updated references from C11->C23

The object representation for floating-point values is implementation defined. However, an implementation that defines the __STDC_IEC_559__ macro shall conform to the IEC 60559 floating-point standard and uses what is frequently referred to as IEEE 754 floating-point arithmetic [ISO/IEC 9899:20112024]. The floating-point object representation used by IEC 60559 is one of the most common floating-point object representations in use today.

...

Using the object representation of a floating-point value for comparisons can lead to incorrect equality results, which can lead to unexpected behavior.

Rule

Severity

Likelihood

Remediation Cost

Priority

Level

FLP37-C

Low

Unlikely

Medium

P2

L3

Automated Detection

Tool

Version

Checker

Description

Astrée
Include Page
Astrée_V
Astrée_V
memcmp-with-floatPartially checked
Axivion Bauhaus Suite

Include Page
Axivion Bauhaus Suite_V
Axivion Bauhaus Suite_V

CertC-FLP37Fully implemented
Cppcheck Premium

Include Page
Cppcheck Premium_V
Cppcheck Premium_V

premium-cert-flp37-cFully implemented
Helix QAC

Include Page
Helix QAC_V
Helix QAC_V

C5026

C++3118


Klocwork

Include Page
Klocwork_V
Klocwork_V

MISRA.STDLIB.MEMCMP.PTR_ARG_TYPES
CERT.MEMCMP.FLOAT_MEMBER


LDRA tool suite
Include Page
LDRA_V
LDRA_V
618 SEnhanced Enforcement
Parasoft C/C++test

Include Page
Parasoft_V
Parasoft_V

CERT_C-FLP37-c

Do not use object representations to compare floating-point values

PC-lint Plus

Include Page
PC-lint Plus_V
PC-lint Plus_V

2498, 2499

Fully supported

Polyspace Bug Finder

Include Page
Polyspace Bug Finder_V
Polyspace Bug Finder_V

CERT C: Rule FLP37-CChecks for memory comparison of floating-point values (rule fully covered)
PVS-Studio

Include Page
PVS-Studio_V
PVS-Studio_V

V1014
RuleChecker

Include Page
RuleChecker_V
RuleChecker_V

memcmp-with-floatPartially checked
TrustInSoft Analyzer

Include Page
TrustInSoft Analyzer_V
TrustInSoft Analyzer_V


Exhaustively verified.

Related Vulnerabilities

Search for vulnerabilities resulting from the violation of this rule on the CERT website.

Bibliography

[ISO/IEC 9899:
2011
2024]Annex F, "ISO/IEC 60559 floating-point arithmetic"

...


...

Image Modified Image Modified Image Modified