Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Nominal or Physical?
#1
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?
#2
I regard it same as int and long.

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

l32a = i32a /* not compliant? */

So...does that mean the conversion is compliant or not?
#4
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.
#5
MISRA Reply Wrote:Section 6.1.2.5 of the C standard orders...

You mean, 6.2.5, yes?
#6
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.
<t></t>


Forum Jump:


Users browsing this thread: 4 Guest(s)