Menu

Please consider this a true warning instead of style warning.

2020-07-17
2020-07-17
  • Hans Nelisse

    Hans Nelisse - 2020-07-17

    Recently I made the following mistake in my code:

    if( data[0] & 0x7F == 0x11 )
    {

    }

    I was glad that CppCheck noticed the mistake. But it was shown as a style error. Would you please consider to show this kind of error as real warnings instead of style warning. Because this kind of mistakes really break the functionality of the code.

     
  • Daniel Marjamäki

    The rule right now is that we use error if there IS undefined behavior whenever the code is executed. The warning severity means there can be undefined behavior.

    I can agree that the name "style" is misleading. Most of the checks that use that severity tries to find suspicious code that can lead to real bugs. We try to avoid purely stylistic checks.

    If Cppcheck finds suspicious code it is impossible to say if there is a bug or not. Maybe the code works exactly as the programmer wants.

     

    Last edit: Daniel Marjamäki 2020-07-17

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.