This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Compiler: TI v18.1.4LTS + TI v18.1.3LTS - static_cast Enum Class Comparison Fails

Tool/software: TI C/C++ Compiler



// Code Fails enum class A : int { ONE = 1, TWO, THREE }; static_assert(static_cast<A>(1) == A::ONE,"ERROR"); // Code Passes enum class B { ONE = 1, TWO, THREE }; static_assert(static_cast<B>(1) == B::ONE,"ERROR");

The above code shows the bug. The following code also fails:

volatile auto var2 = static_cast<A>(1);

When a breakpoint is set on var2, the debugger shows the type as "Enum A" but the value is "0x0000" instead of the expected "ZN1A3ONEE"

This appears to be a compiler bug as MSP430 GCC and other mainstream compilers do not show this behavior.

Update:

Tested using the above code on a brand new project

Linux Commandline 18.1.4: Works

Linux CCS 8.2 - 18.1.4: Works

Windows CCS 8.2 - 18.1.3 + 18.1.4: Error

This appears to be a Windows CCS issue

  • Thank you for reporting these problems, and for providing a test case.  I can reproduce the same results.  I filed CODEGEN-5791 in the SDOWP system to have this investigated.  

    These problems do not occur when I use compiler version 18.12.0.LTS.  So that is another workaround to consider.

    Thanks and regards,

    -George