Menu

Is this invalidScanfArgType_int a false positive warning?

AlexHsieh
6 days ago
4 days ago
  • AlexHsieh

    AlexHsieh - 6 days ago

    Using cppcheck 2.18.0 to check this code:

    struct ST {
        unsigned char  a[1];
    };
    void f(){
        ST st;
        sscanf("1", "%hhu", st.a);
    }
    

    got this warning:

    test.cpp:6:5: warning: %hhu in format string (no. 1) requires 'unsigned char *' but the argument type is 'const char *'. [invalidScanfArgType_int]
        sscanf("1", "%hhu", st.a);
        ^
    

    Is this a false positive warning?

     
  • CHR

    CHR - 6 days ago

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

     
  • AlexHsieh

    AlexHsieh - 4 days ago

    Thank you for confirming.

     

Log in to post a comment.