Uploaded image for project: 'Embedded Software & Tools'
  1. Embedded Software & Tools
  2. EXT_EP-9853

Plain char chosen as the underlying type of an enumerated type

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Medium Medium
    • Code Generation Tools
    • CODEGEN-7597
    • Hide
      MSP430_20.2.0.LTS
      ARM_18.12.0.LTS
      PRU_2.4.0*
      MSP430_18.12.0.LTS
      PRU_2.3.0
      ARP32_1.1.0*
      ARM_20.2.0.LTS
      ARP32_1.0.9
      Show
      MSP430_20.2.0.LTS ARM_18.12.0.LTS PRU_2.4.0* MSP430_18.12.0.LTS PRU_2.3.0 ARP32_1.1.0* ARM_20.2.0.LTS ARP32_1.0.9
    • Hide
      MSP430_20.2.2.LTS
      ARM_20.2.2.LTS
      C2000_18.12.6.LTS
      PRU_2.3.4*
      MSP430_18.12.6.LTS
      ARM_18.12.6.LTS
      C2000_20.2.2.LTS
      Show
      MSP430_20.2.2.LTS ARM_20.2.2.LTS C2000_18.12.6.LTS PRU_2.3.4* MSP430_18.12.6.LTS ARM_18.12.6.LTS C2000_20.2.2.LTS
    • 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.

            syncuser TI User
            syncuser TI User
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: