Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Does "u8 = 6L;" violate rule 10.3
#4
The TC1 Clarification of Exception 1 of rule 10.3 states.
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


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)