srl100 - 2022-11-02

Cppcheck version 2.9

I'm seeing MISRA violations when checking what appears to be valid code:

typedef struct
{
    int len;
    const char buf[8];
} TestStruct;

static TestStruct t1 =          /* Accepted by CppCheck - OK */
{
    5, { 'a', 'b', 'c', 'd', 'e', '\0', '\0', '\0' }
};

static TestStruct t2 =          /* Should be valid but warning 9.2 is raised */
{
    5, { "abcde" }
};

static char t4[8] = "Hello";    /* Should be valid but warning 7.4 is raised */

Source\test2.c:17:21: misra-c2012-7.4
Source\test2.c:12:19: misra-c2012-9.2

 

Last edit: srl100 2022-11-02