Menu

Inconsistent behavior in autoVariable checker

safans
4 days ago
3 days ago
  • safans

    safans - 4 days ago

    Hi, I found an inconsistent behavior in the autoVariables checker.

    The following two cases are semantically equivalent. However, cppcheck correctly flags the first program with an autoVariables warning, while missing the issue in the second program. Therefore, I believe this is a false negative bug.

    static void foo(int **a)
    {
        int b = 1;
        *a = &b;
    }
    int main()
    {
        int *c;
        foo(&c);
        return 0;
    }
    
    static void foo(int **a)
    {
        auto b = 1;
        *a = &b;
    }
    int main()
    {
        int *c;
        foo(&c);
        return 0;
    }
    

    Version: 2.19.0

     
  • CHR

    CHR - 4 days ago

    Please check with current head, I'm getting a warning for both examples.

     
  • safans

    safans - 3 days ago

    Thank you! I verified it with a newer version and Cppcheck caught the warning. It's indeed an old bug.

     

Log in to post a comment.

Auth0 Logo