MISRA Discussion Forums

Full Version: Nominal or Physical?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
10.1a prohibits implicit conversions of an integer expression if it is not to a type wider than the underlying type (and of the same signedness). Suppose ints are the same size as shorts on my system, can I implicitly convert an short to an int? Technically, the ints are not wider than shorts, but nominally, they are. Any thoughts?
I regard it same as int and long.

l32a = i32a /* not compliant? */
bigpan Wrote:I regard it same as int and long.

l32a = i32a /* not compliant? */

So...does that mean the conversion is compliant or not?
Section 6.1.2.5 of the C standard orders the four signed integer types as signed char, short int, int, and long int. It specifies that the range of each type is a sub range of the values of the next type in the list. Therefore int can be considered to be wider than short and an implicit conversion is allowed. The same applies for the unsigned integer ranges.
MISRA Reply Wrote:Section 6.1.2.5 of the C standard orders...

You mean, 6.2.5, yes?
Section 6.1.2.5 in the C90 standard (on which MISRA C is based) corresponds (roughly) to 6.2.5 in the C99 standard.