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.

c6000 cl6x 7.6.0: MISRA warnings 10.1 & 10.5 reported on constants

To my understanding for lines 9 to 11...

* "1u" is an unsigned integer constant that is compatible with e.g. an unsigned char or wider.

* "1Lu" is an unsigned integer constant that is compatible with e.g. an unsigned char or wider.

* "1LLU" is some unsinged long integer constant that is compatible with e.g. an unsigned char.

I would expect the typical math/logic operations on such a constant to result in an unsigned (long) integer as well.

For line 13 i have no understanding as that value is an unsigned integer that is only compatible with an unsigned integer or wider.

(As of now I am not absolutely sure if I still have some basic misunderstanding here. But some parts might still be a problem.)

sample compiler invocation:

C:\SW_TOOLS-trunk\compilers\c6000_7_6_0\bin\cl6x.exe file.c --check_misra=required,advisory,-1.1,-6.3
"file.c", line 9: warning: (MISRA-C:2004 10.5/R) If the bitwise operators ~ and << are applied to an operand of underlying type unsigned char or unsigned short, the result shall be immediately cast to the underlying type of the operand
"file.c", line 10: warning: (MISRA-C:2004 10.5/R) If the bitwise operators ~ and << are applied to an operand of underlying type unsigned char or unsigned short, the result shall be immediately cast to the underlying type of the operand
"file.c", line 11: warning: (MISRA-C:2004 10.5/R) If the bitwise operators ~ and << are applied to an operand of underlying type unsigned char or unsigned short, the result shall be immediately cast to the underlying type of the operand
"file.c", line 12: warning: (MISRA-C:2004 10.5/R) If the bitwise operators ~ and << are applied to an operand of underlying type unsigned char or unsigned short, the result shall be immediately cast to the underlying type of the operand
"file.c", line 13: warning: (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 the expression is complex

file.c:

extern void a(void);

void a(void)
{
    unsigned int s = 6u;
    unsigned int u;
    unsigned int v;

    u = 1u << s;
    u = 1Lu << s;
    u = 1LLu << s;
    u = 0x08000u << s;
    u = 0x10000u << s;

#if 0
    u = ((unsigned char)1u) << s;
    u = ((unsigned short)1u) << s;
#endif
    u = ((unsigned int)1u) << s;

    v = 1u;
    u = v << s;

    (void)(u);
}

  • Thank you for submitting a test case.  I can reproduce those diagnostics.  I filed SDSCM00050006 in the SDOWP system to have this investigated.  Feel free to follow it with the SDOWP link below in my signature.

    Thanks and regards,

    -George