Possible false positive (cpp:S4962)

Hello, we think we have another false positive raised. Here is the code sample:

static struct my_context {
    pthread_t thread;
    bool run;
} my_test = { 0 };

my_test = { 0 }; is being report as (cpp:S4962)

While trying the follwoing code the issue dissapears:

static struct my_context {
    pthread_t thread;
    bool run;
} my_test = { nullptr };

pthread_t is defined in Amazon FreeRTOS POSIX V1.1.0 freertos/posix/include/FreeRTOS_POSIX/sys/types.h

Our setup:
SonarLint v3.11.0 - not connected to server.
SonarQube server - 9.5.0

Both SonarLint and SonarQube server reports issues.

Thank you.

Hi @Ovidijus,

pthread_t is a void pointer and you are initializing it to 0 instead of nullptr, why do you think this is a false-positive?

The rule is correctly detecting that you should use nullptr instead of 0.

Thanks,

Hello,

You are correct this was my mistake.

Thank you.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.