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.

False positive MISRA-C:2004 10.1/R

When compiling my source code I get some MISRA warnings in one function. The warning is not issued for the same code in another function of the same compilation unit. The warning is:

#1393-D (MISRA-C:2004 10.1/R) The value of an expression of integer type shall not be implicitly converted to a different underlying type if it is not a conversion to a wider integer type of the same signedness

The code is:

typedef enum { Result_Ok, Result_Error } EResult;

static void foo(EResult Result)
{
  if (Result_Ok == Result) 
  {    /* do something */
  }
}

static void bar(EResult Result)
{
  if (Result_Ok == Result) 
  {    /* do some other things */
  }
}

The MISRA warning is reported for the if statement in the function foo but not inf function bar.

  1. What's wrong with comparing an enumeration member with the value of a variable of the enumeration type?
  2. Why can't the compiler choose to report an warning or not? It should be consistent.

I am using CCS 5.1.0.201205041800.

  • This sounds similar to an already reported bug SDSCM00044056. The bug is still open and you may track the status of the bug using the SDOWP link in my signature.