Menu

[unknownEvaluationOrder] false positive

Adel Mamin
6 days ago
6 days ago
  • Adel Mamin

    Adel Mamin - 6 days ago
    > cppcheck --version
    Cppcheck 2.18.3
    

    File test.c:

    struct foo {
      int foo;
    };
    
    struct bar {
      struct foo foo;
    };
    
    struct baz {
      struct bar bar;
    };
    
    int main(void) {
      struct baz baz = {.bar = {.foo = {.foo = 1}}};
    
      return 0;
    }
    

    The error:

    > cppcheck test.c
    Checking test.c ...
    test.c:14:34: error: Expression '.foo={.foo=1}' depends on order of evaluation of side effects [unknownEvaluationOrder]
      struct baz baz = {.bar = {.foo = {.foo = 1}}};
                                     ^
    
     
  • CHR

    CHR - 6 days ago

    Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/14431

     

Log in to post a comment.