![]() |
![]() |
1264 | ![]() |
||||
![]() | |||||||
| Arithmetic type - Assignment | |||||||
This message is issued whenever a suffixed floating constant undergoes an assigning conversion to a different floating type. Consider changing the suffix to match the assigned-to type. Remember, an unsuffixed floating constant is always of type double. A constant of type float is suffixed with "F", and a constant of type long double is suffixed with "L". For example:
/*PRQA S 1-9999 ++*/
/*PRQA S 1264, 1265 --*/
extern float fta;
extern double dba;
extern long double lda;
void foo (float a);
float f1264 (void)
{
fta = 5.3F;
fta = 5.3; /* 1265 */
fta = 5.3L; /* 1264 */
dba = 5.3F; /* 1264 */
dba = 5.3;
dba = 5.3L; /* 1264 */
lda = 5.3F; /* 1264 */
lda = 5.3; /* 1265 */
lda = 5.3L;
foo (5.3L); /* 1264 */
return 5.3L; /* 1264 */
}
MISRA-C:2004 Rules applicable to message 1264:
| 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 |
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 |