01-06-2020, 01:18 PM
The TC1 Clarification of Exception 1 of rule 10.3 states.
The code should be written as uint16_t x = 50000U;
Quote:"An essentially signed integer constant expression, with a rank no greater than signed int, may be assigned to an object of essentially unsigned type if its value can be represented in that type.The C standard type ( and essential type) of 50000 is "signed long" for a 16-bit int. TC1 clarifies that exception 1 does not apply.
The code should be written as uint16_t x = 50000U;
Posted by and on behalf of the MISRA C Working Group