Cppcheck (version 2.3) have been serving me really well, but yesterday I came across to an internalAstError.
The following C code assigns to a the fifth element on an array initialized using a compound literal and designators to initialize its elements.
Although it compiles and runs fine using GCC, Clang and TCC without warnings (-Wpedantic -Wall -Wextra), running the bellow gives the following output:
Looking at the value flow (as far as I understand it), it seems that cppcheck doesn't quite parse this expression correctly though.
(Added missing parentheses.)
Last edit: CHR 2021-02-09
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello
Cppcheck (version 2.3) have been serving me really well, but yesterday I came across to an internalAstError.
The following C code assigns to
athe fifth element on an array initialized using a compound literal and designators to initialize its elements.Although it compiles and runs fine using GCC, Clang and TCC without warnings (-Wpedantic -Wall -Wextra), running the bellow gives the following output:
However, this seems to run fine:
Or this, but this one raises
[unusedFunction]when run with --enable=all:I saw on Trac this issue, but I dunno if it is related: https://trac.cppcheck.net/ticket/9513
Thanks in advance!
Last edit: Bento Borges Schirmer 2020-12-28
Adding parentheses around the cast also avoids the warnings:
Looking at the value flow (as far as I understand it), it seems that cppcheck doesn't quite parse this expression correctly though.
(Added missing parentheses.)
Last edit: CHR 2021-02-09
I have created a ticket: https://trac.cppcheck.net/ticket/10177