MISRA Discussion Forums
Do enumerators count as "numeric values"? - 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.6 Types (https://forum.misra.org.uk/forumdisplay.php?fid=33)
+---- Thread: Do enumerators count as "numeric values"? (/showthread.php?tid=724)



Do enumerators count as "numeric values"? - gs - 25-03-2010

The commentary in the MISRA guidelines leaves the answer to this question unclear in my opinion due to the wording
Quote:Numeric values/data are numbers such as 0, 5, 23, \x10, -3.



Re: Do enumerators count as "numeric values"? - misra-c - 13-05-2010

This line appears in Rule 6.2 which concerns the values that can be stored in signed and unsigned char types.

Enumerators count as numeric values provided that the value can be represented in the signed or unsigned char type.

Code:
enum colour { red = 0, amber = 127, green = 255};
signed char s1 = red;          /* Compliant     */
signed char s2 = amber;        /* Compliant     */
signed char s3 = green;        /* Non-compliant */
A future version of MISRA C may place further restrictions on the use of enumerators.