MISRAC2004-10.4
In this section:
Synopsis
(Required) The value of a complex expression of floating type shall only be cast to a floating type which is narrower or of the same size.
Enabled by default
Yes
Severity/Certainty
Low/Medium

Full description
A complex expression of floating type was found that is cast to a wider or different underlying type.
Coding standards
- MISRA C:2004 10.4
(Required) The value of a complex expression of floating type shall only be cast to a floating type which is narrower or of the same size.
Code examples
The following code example fails the check and will give a warning:
void example(void) {
float array[10];
// architecture dependant
double x = (double)(array[5] + 3.0f);
}
The following code example passes the check and will not give a warning about this issue:
void example(void) {
float array[10];
// A non complex expression is considered safe
double x = (double)(array[5]);
}