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.4.2 reports MISRA-C:2004 Requirement 12.2 without file/line indication

The second compiler warning is missing the nearly anywhere else included file/line reference.

C:\SW_TOOLS-trunk\compilers\c6000_7_4_2\bin\cl6x.exe file.c --check_misra=required,advisory,-1-5,-7-11,-12.4,-12.5,-12.6,-12.13,-13-20
"file.c", line 35: warning: (MISRA-C:2004 6.2/R) signed and unsigned char type shall be used only for the storage and use of numeric values
Warning: (MISRA-C:2004 12.2/R) The value of an expression shall be the same under any order of evaluation that the standard permits

file.c:

typedef unsigned int size_t;

static char * strncpy(
    register char * dest,
    register const char * src,
    register size_t n)
{
    if (n) 
    {
        register char       *d = dest;
        register const char *s = src;

        while ((*d++ = *s++) && --n);              /* COPY STRING         */ /* ### this is line #35 ### */

        if (n-- > 1) do *d++ = '\0'; while (--n);  /* TERMINATION PADDING */
    }
    return dest;
}

void a(void)
{
    char d[8] = "";
    char s[8] = "1234";

    strncpy (d, s, 4);
}

source of the above example is partially c6000_7_4_2\include\string.h

  • Thank you for submitting this issue.  I can reproduce that faulty diagnostic.  I filed SDSCM00049993 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

  • As of C6000 compiler version 8.0.0, the MISRA diagnostic shows the file and line number in that file.  If you want to see the exact point (column) at which the diagnostic is issued, use the parser option --verbose_diagnostics (-pdv).  The compiler will show you the source line with a caret (^) pointing to the column of the error:

    % armcl --check_misra=12.2 try1.c -pdv
    "try1.c", line 13: warning: (MISRA-C:2004 12.2/R) The value of an expression
              shall be the same under any order of evaluation that the standard
              permits
              while ((*d++ = *s++) && --n);     // MISRA 12.2 here
                                   ^
    

    This issue has not been addressed on the 7.4.x branch