Hi all, i compiled the current 2.14 version and found that it created unused struct member errors in comparison to my execution before with 2.12. I made some tests and narrowed it down, that it only happens if i define the struct in the header file.
Output from 2.14-dev:
test2 is corectly detected as unused but test1 is not.
$cppcheck--enable=all--dumpsrc/main2.csrc/main2.hCheckingsrc\main2.c...src\main2.c:6:16:style:Variable'test.test1'isassignedavaluethatisneverused.[unreadVariable]test.test1=5;^1/2fileschecked55%doneCheckingsrc\main2.h...src\main2.h:2:9:style:structmember'Test::test1'isneverused.[unusedStructMember]inttest1;^src\main2.h:3:9:style:structmember'Test::test2'isneverused.[unusedStructMember]inttest2;^2/2fileschecked100%donenofile:0:0:information:Activecheckers:106/592(use--checkers-report=<filename> to see details) [checkersReport]
Putting both into one file in 2.14-dec the test is fully correct.
$cppcheck--enable=all--dumpsrc/main2.cCheckingsrc\main2.c...src\main2.c:4:9:style:structmember'Test::test2'isneverused.[unusedStructMember]inttest2;^src\main2.c:10:16:style:Variable'test.test1'isassignedavaluethatisneverused.[unreadVariable]test.test1=5;^nofile:0:0:information:Activecheckers:106/592(use--checkers-report=<filename> to see details) [checkersReport]
Somehow in between versions this broke.
I am not exactly sure (as i am on my work pc now and not on the home pc where i builded the version but the base commit is likely 503c109a1c569b3f4da76582634d226432debda8). Currently can not confirm it on the main due to not able to rebuild but checking commit history does not look to have any changes regarding this.
Last edit: Sven Wienand 2024-02-13
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I don't think warnings about unused members from a header are desirable, since your program might not be the only one which consumes that header.
Edit: Why are you explicitly checking headers on their own?
Last edit: CHR 2024-02-13
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am checking header as guys in my company said that they once had problems with the headers not fully checked. And they started checking heads explicitely. I also noticed that in the dump file of the c file the included headers are parsed. Am a correct that the full header file will be put as tokens within the c file? Exactly like i would check them their own?
I don't think warnings about unused members from a header are desirable
Yeah if i understand you correctly it is exactly what i was proposing. The unusedMember warning in the header file is a false positive. So the unused member warning shouldn't be there in the 2.14 development version. And this warning wasn't there in 2.12. Therefore some changes caused this false positive. Or did i miss understand you?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi all, i compiled the current 2.14 version and found that it created unused struct member errors in comparison to my execution before with 2.12. I made some tests and narrowed it down, that it only happens if i define the struct in the header file.
Build Windows Version.
Example Code
main2.h
main2.c
Output from 2.12:
Not sure why 2.12 does not show the unused member here because in my main program i definatly get correct unused member warnings.
Output from 2.14-dev:
test2 is corectly detected as unused but test1 is not.
Putting both into one file in 2.14-dec the test is fully correct.
Somehow in between versions this broke.
I am not exactly sure (as i am on my work pc now and not on the home pc where i builded the version but the base commit is likely 503c109a1c569b3f4da76582634d226432debda8). Currently can not confirm it on the main due to not able to rebuild but checking commit history does not look to have any changes regarding this.
Last edit: Sven Wienand 2024-02-13
I don't think warnings about unused members from a header are desirable, since your program might not be the only one which consumes that header.
Edit: Why are you explicitly checking headers on their own?
Last edit: CHR 2024-02-13
I am checking header as guys in my company said that they once had problems with the headers not fully checked. And they started checking heads explicitely. I also noticed that in the dump file of the c file the included headers are parsed. Am a correct that the full header file will be put as tokens within the c file? Exactly like i would check them their own?
Yeah if i understand you correctly it is exactly what i was proposing. The unusedMember warning in the header file is a false positive. So the unused member warning shouldn't be there in the 2.14 development version. And this warning wasn't there in 2.12. Therefore some changes caused this false positive. Or did i miss understand you?
Yes.
I would say 2.14dev works as expected, it is told to check the header on its own, and the unused members are reported. Not sure what happens in 2.12.
okay understand your argument. Based on your feedback i will stop checking heads directly
Case Closed
Last edit: Sven Wienand 2024-02-13