MISRA Discussion Forums
Nominal or Physical? - Printable Version

+- MISRA Discussion Forums (https://forum.misra.org.uk)
+-- Forum: MISRA C (https://forum.misra.org.uk/forumdisplay.php?fid=4)
+--- Forum: MISRA-C: 2004 rules (https://forum.misra.org.uk/forumdisplay.php?fid=17)
+---- Forum: 6.10 Arithmetic Type Conversions (https://forum.misra.org.uk/forumdisplay.php?fid=37)
+---- Thread: Nominal or Physical? (/showthread.php?tid=28)



Nominal or Physical? - gs - 23-03-2005

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?


- bigpan - 24-03-2005

I regard it same as int and long.

l32a = i32a /* not compliant? */


Re: - gs - 24-03-2005

bigpan Wrote:I regard it same as int and long.

l32a = i32a /* not compliant? */

So...does that mean the conversion is compliant or not?


MISRA reply to question - MISRA Reply - 12-05-2005

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.


Re: MISRA reply to question - gs - 12-05-2005

MISRA Reply Wrote:Section 6.1.2.5 of the C standard orders...

You mean, 6.2.5, yes?


Nominal or Physical? - Paul Burden - 13-05-2005

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.