![]() |
![]() |
4462 | ![]() |
||||
![]() | |||||||
| Arithmetic type - Assignment | |||||||
This message is issued whenever a non-constant expression of essentially floating type undergoes an assigning conversion to a narrower floating type. For example:
/*PRQA S 1-9999 ++*/
/*PRQA S 4462 --*/
void foo (float b);
float f4462 (double a)
{
float fta = a; /* 4462 */
foo (a + 1.0); /* 4462 */
fta = (a - 1.0); /* 4462 */
return a; /* 4462 */
}
For the purposes of QAC conversion messages, types are ordered according to the
configured size (-s option), by default; hence if type float and type double
are both implemented in 64 bits, the types will be considered equivalent.
However, when the -strictrank option is specified, the types will be ordered according to
their rank, and float will be considered narrower
than double.
MISRA-C:2004 Rules applicable to message 4462:
| Rule 10.2 (Required) | The value of an expression of floating type shall not be implicitly converted to a different type if: a) it is not a conversion to a wider floating type, or b) the expression is complex, or c) the expression is a function argument, or d) the expression is a return expression |
![]() | ||
| QA·C Source Code Analyser 8.1
MISRA-C:2004 Compliance Module 3.2 © 2012 Programming Research. www.programmingresearch.com | Personality Groups | Glossary | Message Index | MISRA-C:2004 Rule Index | Contents |