[EXT_EP-10334] enum behavior change on branch: 8-bit enum changes from unsigned to signed Created: 16/Apr/21 Updated: 07/May/21 Resolved: 07/May/21 |
|
Status: | Declined |
Project: | Embedded Software & Tools |
Component/s: | None |
Affects Version/s: | None |
Fix Version/s: | None |
Type: | Bug | Priority: | Not Prioritized |
Reporter: | TI User | Assignee: | TI User |
Resolution: | Won't Fix | Votes: | 0 |
Remaining Estimate: | Not Specified | ||
Time Spent: | Not Specified | ||
Original Estimate: | Not Specified |
Product: | Code Generation Tools |
Internal ID: | CODEGEN-8801 |
Forum URL: | https://e2e.ti.com/support/tools/ccs/f/81/t/993701 |
Found In Release: | ARM_20.2.4.LTS |
Affected Platform/Device: | default |
Decline Reason: | The change was intentional to match the intended ABI behavior |
Description |
The test case looks like this: enum e { a=1u, b=2u, c=3u } x; The enumeration values would fit in either a signed char or unsigned char. Either would be a reasonable choice to use as the underlying integer type of the enum type. The choice is made by the compiler according to the rules of the ABI. For the ARM compiler, the choice depends partially on whether the program is compiled in strict ANSI mode and the value of the --enum_type command-line option. (Note that in C, the 'u' suffix on those enumeration constant initializers doesn't impact the type of either the enumeration constants or the underlying type of the enum.) In this case, the compiler is in strict ANSI mode and --enum_type=packed mode. The underlying type chosen by the parser has changed between 20.2.1.LTS and 20.2.2.LTS. This behavior change is deliberate, and due to the fix for The user's code compares a value of the enum type to an unsigned integer that isn't of enum type. 20.2.1.LTS would not have emitted a remark, but 20.2.2.LTS will now emit the remark "comparison between signed and unsigned operands." Remarks do not appear by default unless the user enables them with the --issue_remarks command-line option. Avoid using --issue_remarks or use the -pds2142 option to suppress this particular remark. Alternately, you can force the compiler to prefer "unsigned char" over "signed char" by adding a dummy enumeration constant with the value UCHAR_MAX: #include <limits.h> ; |