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/TMS320F280049: va_arg(list, long); Conversion to unsigned long and not long(Compiler issue)

Genius 5910 points
Part Number: TMS320F280049


Tool/software: TI C/C++ Compiler

This line of code:

  const long value = (long)va_arg(list, long);

Produce the following output:

This solved it:

 const int32_t value11 = va_arg(list, int32_t);

How strange changing the name solves the problem.

This is the complete part of the code:

        case(MSG_UINT32):
                    {
                        const uint32_t value = va_arg(list, uint32_t);
                        Status_MSG_detail(0 , __LINE__, MSG_UINT32, Modid, mesid, msg0, value);
                    }
                    break;
        case(MSG_INT32):
                    {
                        const int32_t value = va_arg(list, int32_t); // this value is changed to value11
                        Status_MSG_detail(0 , __LINE__, MSG_INT32, Modid, mesid, msg0, value);
                    }
                    break;

So somehow the definition of the previous value definition is reused. There is no global value variable.

  • evs said:

    This solved it:

     const int32_t value11 = va_arg(list, int32_t);

    Since long and int32_t are the same type, I don't see how that is possible.  Some other factor must have caused the change in behavior.

    Thanks and regards,

    -George

  • George. You can believe me or not. Changing the variable name solves this issue. 

    My guess is that the compiler is (re)using the variables outside it's brackets in the switch case.  See the previous value declaration in the switch.

  • evs - I am unable to reproduce the issue with CCSv9.3.0. If you can provide a small reproducible test case, that would be great. I would need the source and generated executable (*.out) file. 

    Thanks

    ki