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.

TMS320F280039C: The C2000 compiler does not generate any warnings when ‘=‘ is used instead of ‘==‘ in ‘if’ condition.

Part Number: TMS320F280039C


Tool/software:

I find the C2000 compiler in CCS11.1 does not generate any warnings when ‘=‘ is used instead of ‘==‘ in ‘if’ condition. I want to check these syntax errors in my programs. So how do I configure the compiler in this situation?

  • Hi Devin,

    Can you confirm what compiler version you are using? I'm connecting you with a compiler expert to help further.

    Best Regards,

    Aishwarya

  • The latest version of the C2000 compiler is 22.6.2.LTS.  When I try it, I get a warning.

    % cl2000 --verbose_diagnostics file.c
    "file.c", line 3: warning: use of "=" where "==" may have been intended
          if (arg = 0)
              ^

    The diagnostic is emitted whether or not the option --verbose_diagnostics is used.  This option causes that diagnostic to also show the affected source line, with an indicator to where the error begins.

    Thanks and regards,

    -George

  • Hi Aishwarya,

    Sorry for replying so late. My email marked this email as spam. So I didn't see this reply. The compiler version is v21.6.0.LTS.

    Best regards.

  • Hi George,

    Sorry for replying so late. My email marked this email as spam. So I didn't see this reply. The compiler version is v21.6.0.LTS.

    I find if ‘arg’ in your code is a global variable, the diagnostic will indeed appear. However, there is no diagnostic when ‘arg’ is a local variable. I’m confused about it.

    Best regards.

  • there is no diagnostic when ‘arg’ is a local variable

    I am unable to reproduce that result.  For the source file where this occurs, please follow the directions in the article How to Submit a Compiler Test Case.  

    Thanks and regards,

    -George

  • I have created a project with only 'main.c' source file. The code in the 'main.c' is shown below.

    int global, global1;
    void main(void)
    {
        int i;
        if(global = global1){
            i++;
        }
        if(i = global1){
            i++;
        }
    }

    My previous description was incorrect. I originally thought it was a problem on the left side of '='. In fact, there is no diagnostic if the right side of '=' is a global variable. The compiler version is v21.6.0.LTS.

    Best regards.

  • Thank you for the test case.  I am able to reproduce the same behavior.  I filed EXT_EP-12882 to have this investigated.  You are welcome to follow it with that link.  Note the issue is not considered a bug, but a request to improve the diagnostics issued by the compiler.

    Thanks and regards,

    -George