08-06-2018, 07:38 AM
Rule 10.1 knowingly includes violations on code that is well-defined. This is to enable a rule to be produced that is simple to understand and to check. Your particular example is well-defined in producing a result, but there are two ways in general that a shift on an expression with a signed type may fail.
In section 6.5.7 on the C99 Standard
You are correct to highlight that rationale 6 only mentions implementation-defined behaviour. It should also mention the undefined behaviour given above.
In section 6.5.7 on the C99 Standard
Quote: 4 ... If E1 has a signed type and nonnegative value, and E1x2^E2 is representable in the result type, then that is the resulting value; otherwise, the behavior is undefined.
5 ... If E1 has a signed type and a negative value, the resulting value is implementation-defined.
You are correct to highlight that rationale 6 only mentions implementation-defined behaviour. It should also mention the undefined behaviour given above.
Posted by and on behalf of the MISRA C Working Group