Marcus Gigandet - 6 days ago

Hello, I've just upgraded a codebase using cppcheck 2.10 to 2.17.1 and then 2.19.1 and have run into an error that I haven't be able to solve, but I have identified the root cause.

Consider the following code:

typedef struct MyStruct
{
    float thing;
} MyStruct_t;

static MyStruct_t myArray[sizeof(MyStruct_t)];

When evaluated on version 2.17.1 or higher (tested 2.17.1, 2.19, 2.19.1), it gives the following error:

src\demo.c:6:26: error: Because of missing configuration, misra checking is incomplete. There can be false negatives! Unknown array size, please review configuration [misra-config]
static MyStruct_t myArray[sizeof(MyStruct_t)];

It correctly evaluates the size if you replace sizeof(MyStruct_t) with a primitive like sizeof(float); however, it fails to evaluate the size of any given struct.