Menu

MFC CString inside struct: wrong printf-string not detected

2020-04-14
2020-04-14
  • Sebastian Weiser

    cppcheck 1.90

    In this little code, the format string does not match the parameter type. In the first call for CString::Format, this is detected as warning (invalidPrintfArgType_sint), but in the 2nd example inside a struct it is not detected.

    typedef struct {
        CString st;
    } my_struct_t;
    
    void my_func(void) {
        CString my_string;
        double d = 3.1415;
        my_string.Format("%d", d);
    
        my_struct_t my_struct;
        my_struct.st.Format("%d", d);
    }
    
     
  • Daniel Marjamäki

    Thanks good catch! I created https://trac.cppcheck.net/ticket/9672

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.