This give the error for me:
int main()
{
{"B", (state == true) ? "UNDEF" : "DEF"};
}
I know that it does not compile, but e.g. adding 'A b[] =' in front hide the error.
I run cppcheck without any commandline options.
Btw, I compiled cppcheck without Z3, since that did not compile in my environment (I think there is another discussion about that).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
hmm somehow it would feel good with a bit more reasonable syntax. Missing type/variable declarations is fine, I don't worry about that. Is it possible for you to bisect your code and try to keep a reasonable syntax?
just so we do not make a fix for your example code and that will not help anybody in reality.
Last edit: Daniel Marjamäki 2020-05-19
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
not sure if it is correct to reuse this one, but seem to be related.
When I run cppcheck 2.2 on the code snip below I get
AST broken, ternary operator missing operand(s) [internalAstError]
Running cppcheck 2.0 on lines of code like this:
{"B", (state == true) ? "UNDEF" : "DEF"};
The output is
AST broken, ternary operator missing operand(s) [internalAstError]
Changing to
{"B", state == true ? "UNDEF" : "DEF"};
the error is not there.
It does not happen in cppcheck 1.90
can you show how I can reproduce?
I get no such error for this code:
This give the error for me:
int main()
{
{"B", (state == true) ? "UNDEF" : "DEF"};
}
I know that it does not compile, but e.g. adding 'A b[] =' in front hide the error.
I run cppcheck without any commandline options.
Btw, I compiled cppcheck without Z3, since that did not compile in my environment (I think there is another discussion about that).
hmm somehow it would feel good with a bit more reasonable syntax. Missing type/variable declarations is fine, I don't worry about that. Is it possible for you to bisect your code and try to keep a reasonable syntax?
just so we do not make a fix for your example code and that will not help anybody in reality.
Last edit: Daniel Marjamäki 2020-05-19
Absolutely fair request.
This example compiles and still exposed the error.
Thanks! I created https://trac.cppcheck.net/ticket/9734
There is another AST broken: 'if' doesn't have two operands.
https://github.com/zufuliu/notepad2/blob/master/scintilla/src/PerLine.cxx#L78
Thanks! I created this trac ticket: https://trac.cppcheck.net/ticket/9729
Hi,
not sure if it is correct to reuse this one, but seem to be related.
When I run cppcheck 2.2 on the code snip below I get
AST broken, ternary operator missing operand(s) [internalAstError]
Not there with cppcheck 2.1.