...
Converting a floating-point value to a floating-point value of a smaller range and precision or to an integer type, or converting an integer type to a floating-point type, can result in a value that is not representable in the destination type and is undefined behavior on implementations that do not support Annex F.
Rule | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
FLP34-C | Low | Unlikely | Low | P3 | L3 |
Automated Detection
Tool | Version | Checker | Description | ||||
---|---|---|---|---|---|---|---|
Astrée |
|
Supported, but no explicit checker | |
Compass/ROSE |
Can detect some violations of this rule. However, it does not flag implicit casts, only explicit ones | |||||||||
| MISRA_CAST (needs verification) | Can detect instances where implicit float conversion is involved: implicitly converting a complex expression with integer type to floating type, implicitly converting a double expression to narrower float type (may lose precision), implicitly converting a complex expression from | |||||||
LDRA tool suite |
| 435 S, 93 S | Partially implemented | ||||||
Parasoft C/C++test |
|
|
| MISRA2004-10_1_d | Partially implemented | |||
Polyspace Bug Finder | R2016a | Float conversion overflow, Integer conversion overflow, Unsigned integer conversion overflow |
Overflow when converting between floating point data types Overflow when converting between integer types Overflow when converting between unsigned integer types | |||||||||
PRQA QA-C |
| 4450, 4451, | Partially implemented |
PRQA QA-C++ |
3011 | |||
PVS-Studio | 6.22 | V615, V2003, V2004 | General analysis and Customer specific rule sets |
Related Vulnerabilities
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
...
Key here (explains table format and definitions)
Taxonomy | Taxonomy item | Relationship |
---|---|---|
CERT Oracle Secure Coding Standard for Java | NUM12-J. Ensure conversions of numeric types to narrower types do not result in lost or misinterpreted data | Prior to 2018-01-12: CERT: Unspecified Relationship |
ISO/IEC TR 24772:2013 | Numeric Conversion Errors [FLC] | Prior to 2018-01-12: CERT: Unspecified Relationship |
CWE 2.11 | CWE-681, Incorrect Conversion between Numeric Types | 2017-06-29: CERT: Rule subset of CWE |
CWE 2.11 | CWE-197 | 2017-06-14: CERT: Rule subset of CWE |
CERT-CWE Mapping Notes
Key here for mapping notes
...
CWE-681 = Union( FLP34-C, INT31-C)
Bibliography
[IEEE 754 2006] |
[ISO/IEC 9899:2011] | Subclause 6.3.1.4, "Real Floating and Integer" Subclause 6.3.1.5, "Real Floating Types" |
...
...