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.

C/C++ Compiler generates false positive MISRA warnings

When I enable MISRA rules check for the C/C++ compiler for MSP430 I get the MISRA warning 10.1/R for the following code.

typedef enum _MyEnum { One, Two } MyEnum; 
MyEnum MyVariable; 
 
int foo(void) 
{ 
    int result = 1; 
 
    if (One == MyVariable)  // fails here with MISRA-C:2004 10.1/R 
    { 
        result = 2; 
    }     
    return result; 
} 

Our coding style convention requires that the variable is at the right hand side. Therefore I don't want to swap One and MyVariable, although that makes the warning to disappear.

Is that a bug in the MISRA checker? If not, why is the comparison of two terms not commutable?

 

  • Helge,

    I submitted a bug for this issue so it can be analyzed and fixed by the compiler team. The tracking # is SDSCM00044056. Feel free to track the status of the bug using the SDOWP link in my signature.

  • There are some other MISRA 10.1 bug entries and SDSCM00044056 does not include details or a reference to my post.

    Probably you want to add some details to the tracker to help the developers to fix the bug.

    Thank you,
    Helge

  • Helge,

    The bug report does include your test case and a reference to this post, however not all fields are visible when you view it through the external bug interface. So please be assured that the team will have the information they need, and if they happen to need anything more when they're analyzing the issue, we will request this in this thread.