Posts: 87
Threads: 68
Joined: Nov 2004
Reputation:
0
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?
Posts: 2
Threads: 1
Joined: Feb 2005
Reputation:
0
I regard it same as int and long.
l32a = i32a /* not compliant? */
<t></t>
Posts: 53
Threads: 2
Joined: Dec 2004
Reputation:
0
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.
Posts: 1
Threads: 0
Joined: Sep 2004
Reputation:
0
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>