-
Bug
-
Resolution: Fixed
-
Medium
-
Code Generation Tools
-
CODEGEN-7597
-
-
-
default
Enumerated types have an underlying integral type; this underlying type dictates the storage size and signedness of the enumerated type. The compiler will try to find the smallest integral type which can hold all of the values of the enumeration constants. When using --enum_type=packed, the compiler is allowed to consider integral types smaller than int. When the enumeration values are small enough to fit in an 8-bit type, the compiler should choose "signed char" or "unsigned char," depending on which one can hold all of the values of the enumeration constants. Sometimes, either type will work. In this case, the compiler is supposed to choose either "signed char" or "unsigned char," but the compiler mistakenly chooses "plain char" without considering whether "plain char" is signed or unsigned. In that case, the signedness of the enumerated type will depend on the --plain_char option. When --enum_type=packed (the default for ARM, PRU, and ARP32 when unspecified) together with --plain_char=unsigned (the default for ARM, MSP430, and PRU when unspecified), the compiler will mistakenly use "unsigned char" for the underlying type when it should use "signed char." This will not affect the correctness of programs which only check variables of enumerated type for equality with enumeration constants, but programs which rely on the signedness of variables of enumerated type may behave differently.