Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Integer type ranges are defined by the JLS, §4.2.1, "Integral Types and Values", [JLS 2005] and are also described in rule "NUM16NUM00-J. Detect or prevent integer overflow."

The table below presents the rules for narrowing primitive conversions of integer types. In the table, for an integer type T, n represents the number of bits used to represent the resulting type T (precision).

...

C Secure Coding Standard

"INT31-C. Ensure that integer conversions do not result in lost or misinterpreted data"

 

"FLP34-C. Ensure that floating point conversions are within range of the new type"

C++ Secure Coding Standard

"INT31-CPP. Ensure that integer conversions do not result in lost or misinterpreted data"

 

"FLP34-CPP. Ensure that floating point conversions are within range of the new type"

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="f643bfafa4a85dcd-709f598a-46bd4c30-8252ae32-2a5d11ee4192590b9c54cdb6"><ac:plain-text-body><![CDATA[

[ISO/IEC TR 24772:2010

http://www.aitcnet.org/isai/]

"Numeric Conversion Errors [FLC]"

]]></ac:plain-text-body></ac:structured-macro>

MITRE CWE

CWE ID 681, "Incorrect Conversion between Numeric Types"

 

CWE ID 197, "Numeric Truncation Error"

...