![]() |
![]() |
4126 | ![]() |
||||
![]() | |||||||
| Arithmetic type - Complex expressions | |||||||
The value of an expression of type float is being cast to type double. Be aware that the expression itself is not evaluated in type double. Message 4126 is generated when the value resulting from four specific operators is of type float and is explicitly cast to type double. However the message will only be generated if the size of type double is greater than the size of type float. The only operators which may trigger this message are * / + and -. The danger associated with this type of operation is that the programmer may assume, incorrectly, that the arithmetic operation is performed in type double rather than type float.
/*PRQA S 2017,3198,3199,3203,3408,3447 ++*/
extern float fta;
extern float ftb;
extern void foo(void)
{
double dba;
dba = fta * ftb; /* Message 4123 */
dba = fta / ftb; /* Message 4123 */
dba = fta + ftb; /* Message 4123 */
dba = fta - ftb; /* Message 4123 */
dba = (double)(fta * ftb); /* Message 4126 */
dba = (double)(fta / ftb); /* Message 4126 */
dba = (double)(fta + ftb); /* Message 4126 */
dba = (double)(fta - ftb); /* Message 4126 */
}
No MISRA-C:2004 Rules applicable to message 4126
See also:
![]() | ||
| 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 |