I think there is a unexpected behaviour with the -U option
Take the sample code below, ugly, isn't it... :) So this code overrides the metasyntaxicvariable in an #ifdef, that will run to a redundantInitialization warning if the DEFINE is available
He is what i try and what are the results :
- remove the cppcheck-suppress redundantInitialization from the code above
- run cppcheck with the -DMY_SUPER_DEFINE_TO_OVERRIDE => ok, redundantInitialization warning is detected
- put back in place the cppcheck-suppress redundantInitialization line like above
- run cppcheck without the -DMY_SUPER_DEFINE_TO_OVERRIDE => ok, no warning as there is no override
- now run cppcheck by specifying we did not want that define with the -UMY_SUPER_DEFINE_TO_OVERRIDE => NOT OK, a new warning appears for an unmatchedSuppression(main.cpp 12 unmatchedSuppression Unmatched suppression: redundantInitialization)
For me, with -U option, we shouldn't have a warning...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I think there is a unexpected behaviour with the -U option
Take the sample code below, ugly, isn't it... :) So this code overrides the metasyntaxicvariable in an #ifdef, that will run to a redundantInitialization warning if the DEFINE is available
He is what i try and what are the results :
- remove the cppcheck-suppress redundantInitialization from the code above
- run cppcheck with the -DMY_SUPER_DEFINE_TO_OVERRIDE => ok, redundantInitialization warning is detected
- put back in place the cppcheck-suppress redundantInitialization line like above
- run cppcheck without the -DMY_SUPER_DEFINE_TO_OVERRIDE => ok, no warning as there is no override
- now run cppcheck by specifying we did not want that define with the -UMY_SUPER_DEFINE_TO_OVERRIDE => NOT OK, a new warning appears for an unmatchedSuppression (main.cpp 12 unmatchedSuppression Unmatched suppression: redundantInitialization)
For me, with -U option, we shouldn't have a warning...
can this topic be created with the content of the found bug ? the "Post awaiting moderation." since 2020-12-10... :/
Last edit: Gildas 2021-01-04
hi sorry we did not respond earlier. thanks for pinging us..
I believe this is a duplicate of https://trac.cppcheck.net/ticket/5704
Yes, i haven't find it when i search ! Sorry for the duplicate...
You have a good memory, the ticket has 7 years !! :D
As it has 7 years, i don't think it'll be resolved in the future... :/
Thanks for your work on this project !!!
I look through all defects now and then and try to fix old problems. Unfortunately this one feels rather tricky to fix.