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.

MISRA 10.1 and 10.3 Warning



I've got MISRA-2004 warnings enabled for required rules. I'm getting a warning and I don't know how to resolve it. I've tried it 2 ways and each way results in a different warning. What am I doing wrong. We are using a F28069. Here is an example:

unsigned int x = 0U;

unsigned int* px;

px = &x; /* 10.1 warning */

px = (unsigned int*)&x; /* 10.3 warning */

  • I cannot explain why the compiler issues those MISRA diagnostics in this case.  So, I filed SDSCM00052021 in the SDOWP system to have this investigated.  There are two possible outcomes.  One, an explanation might be given which explains why the diagnostic issued and how to avoid it.  Two, this is considered a bug in the compiler and fixed.  Feel free to follow this case with the SDOWP link below in my signature.

    Thanks and regards,

    -George

  • I find I am getting the same result.

    One thing to add is that the 10.1 and 10.3 warnings do not seem to occur if x is a pointer. 

    For example:

    unsigned int* x = (unsigned int *)0;

    unsigned int** px;

    px = &x; /* 10.1 and 10.3 OK */

    px = (unsigned int**)&x; /* 10.1 and 10.3 OK */