MISRAC2012-Rule-10.4_b
In this section:
Synopsis
(Required) The second and third operands of the ternary operator shall have the same essential type category.
Enabled by default
Yes
Severity/Certainty
Medium/Low

Full description
The second and third operands of the ternary operator do not have the same essential type category.
Coding standards
- MISRA C:2012 Rule-10.4
(Required) Both operands of an operator in which the usual arithmetic conversions are performed shall have the same essential type category
Code examples
The following code example fails the check and will give a warning:
void example(void) {
int x;
float y;
int z = (x > 0)?x:y;
}
The following code example passes the check and will not give a warning about this issue:
void example(void) {
int x;
float y;
int z = (x > 0)?x:(x+1);
}