Menu

New functionality for checker "Inefficient usage of string::find"?

Martin
2016-01-22
2016-07-07
  • Martin

    Martin - 2016-01-22

    Hi,

    since cppcheck1.72 the code

    void main()
    {
    std::string firstChar = getName();
    if (firstChar.find_first_of("0123456789") == 0)
    return;
    }

    produces the finding

    ./cppcheck --enable=all test.cpp
    Checking ../test.cpp...
    [../test.cpp:4]: (performance) Inefficient usage of string::find() in condition; string::compare() would be faster.

    Is it intentional that now this checker is also used for find_first_of()?

    Thanks,
    Martin

     

    Last edit: Martin 2016-01-23
  • Daniel Marjamäki

    No that looks wrong as far as I see... can you please open a ticket in our issue tracker?

     
  • antred

    antred - 2016-07-05

    Well, you should certainly get a slap on the wrist for void main(), though. :p

     
  • Mr. X

    Mr. X - 2016-07-07

    Anyway, the issue is fixed for a few months already: http://trac.cppcheck.net/ticket/7349

     

Log in to post a comment.