18-02-2016, 08:51 AM
The exception was created for signed literals as coders frequently omit the "U" suffix and it seemed over harsh to prevent such assignments.
If a coder has added the suffix "U", this explicitly signals an intention that the literal should be "unsigned" and therefore should only used in an essentially unsigned context. The view of the working group was that assigning such literals to a signed object could indicate a programming error and should therefore raise a violation.
If a coder has added the suffix "U", this explicitly signals an intention that the literal should be "unsigned" and therefore should only used in an essentially unsigned context. The view of the working group was that assigning such literals to a signed object could indicate a programming error and should therefore raise a violation.
Code:
int8_t s8a = 1u; /*Non-compliant */
Posted by and on behalf of the MISRA C Working Group