OK, this was hard to reproduce but I finally did but it required me to put the enum definition in a different header file instead (which happens to be referenced as ProjectName/HeaderFile.h in the cpp file and is in a completely different location so this could be a case of cppcheck not finding the path that we have managed with CMake to keep our source compiling.
The Header (say path is sourceDir/OtherFolder/ProjectName/Example.h)
enumExampleEnum{val1=0,val2,val3};
The CPP The Header (say path is sourceDir/ProjectName/Example.cpp)
I was told clazy caught this, tried with cppcheck 2.6 and it passed so there might be an opportunity to make the tool better.
I checked and confirmed that enum1 and enum2 were not equal so therefore mode can't be equal to both so the or is always true.
can you please provide a proper example code. with this code I get a warning:
OK, this was hard to reproduce but I finally did but it required me to put the enum definition in a different header file instead (which happens to be referenced as ProjectName/HeaderFile.h in the cpp file and is in a completely different location so this could be a case of cppcheck not finding the path that we have managed with CMake to keep our source compiling.
The Header (say path is sourceDir/OtherFolder/ProjectName/Example.h)
The CPP The Header (say path is sourceDir/ProjectName/Example.cpp)
Maybe I need to figure out how to set paths better in CPPCheck or it could/should scan cmake better?
yes it sounds like a include path problem.. does it work better if you generate and load a compile database.
cppcheck --project=compile_commands.json
I tried that and it still didn't find this issue but I did find others to look into...