Conversions can occur explicitly as the result of a cast or implicitly as required by an operation. While conversions are generally required for the correct execution of a program, they can also lead to lost or misinterpreted data. Conversion of an operand value to a compatible type causes no change to the value or the representation \[ [ISO/IEC 9899:1999|AA. Bibliography#ISO/IEC 9899-1999]\].Wiki Markup
The C99 integer conversion rules define how C compilers handle conversions. These rules include integer promotions, integer conversion rank, and the usual arithmetic conversions. The intent of the rules is to ensure that the conversions result in the same numerical values, and that these values minimize surprises in the rest of the computation. Prestandard C usually preferred to preserve signedness of the type.
...
Recommendation | Severity | Likelihood | Remediation Cost | Priority | Level |
|---|---|---|---|---|---|
INT02-C | medium | probable | medium | P8 | L2 |
Automated Detection
Tool | Version | Checker | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
|
|
...
MITRE CWE: CWE-197, "Numeric Truncation Error"
Bibliography
\[[Dowd 2006|AA. Bibliography#Dowd 06] \] Chapter 6, "C Language Issues" (Type Conversions 223—270)
\[Conversions 223—270)Wiki Markup
[Seacord 2005a|AA. Bibliography#Seacord 05]\] Chapter 5, "Integers"
...
INT01-C. Use rsize_t or size_t for all integer values representing the size of an object 04. Integers (INT)