Do enumerators count as "numeric values"?

6.6 Types

Moderators: misra-c, david ward

Post Reply
Posts: 87
Joined: Thu Nov 18, 2004 1:39 am

Do enumerators count as "numeric values"?

Post by gs » Thu Mar 25, 2010 1:04 pm

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

Posts: 572
Joined: Thu Jan 05, 2006 1:11 pm

Re: Do enumerators count as "numeric values"?

Post by misra-c » Thu May 13, 2010 10:04 am

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: Select all

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.
Posted by and on behalf of
the MISRA C Working Group

Post Reply

Return to “6.6 Types”