Minimal reproducer:
[/tmp]~> cat test.c typedef struct { char *s; int len; } Str; void f(int n) { Str tmp = {0}; Str s = n == 0 ? (Str){0} : tmp; } [/tmp]~> cppcheck test.c Checking test.c ... test.c:6:17: error: Syntax Error: AST broken, ternary operator lacks ':'. [internalAstError] Str s = n == 0 ? (Str){0} : tmp; ^
Wrapping the compound literal in a paren seems to solve it:
[/tmp]~> cat test2.c typedef struct { char *s; int len; } Str; void f(int n) { Str tmp = {0}; Str s = n == 0 ? ((Str){0}) : tmp; } [/tmp]~> cppcheck test2.c Checking test2.c ...
Tested with cppcheck version 2.19.1.
2.19.1
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/14548
Log in to post a comment.
Minimal reproducer:
Wrapping the compound literal in a paren seems to solve it:
Tested with cppcheck version
2.19.1.Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/14548