Opened 7 years ago
Closed 4 years ago
#9479 closed defect (fixed)
internalAstError on typedefed default arguments
| Reported by: | pfultz2 | Owned by: | noone |
|---|---|---|---|
| Priority: | Normal | Milestone: | 2.9 |
| Component: | Other | Version: | |
| Keywords: | ast syntaxError simplifyTypedef | Cc: |
Description
The code compiles with clang and gcc:
typedef int *a; void b(a = a());
But fails on cppcheck with a syntax error:
Syntax Error: AST broken, binary operator '=' doesn't have two operands. [internalAstError]
void b(a = a());
^
Change History (6)
comment:1 by , 7 years ago
| Keywords: | simplifyTypedef added |
|---|
comment:2 by , 6 years ago
comment:3 by , 6 years ago
does it declare a nameless parameter that is initialized with a value?
Yes, its initialized to the default constructed value(ie a() or nullptr).
is it logically equivalent with void b(a)?
Not really. You can't call it without any arguments(ie b()).
can we just remove the redundant initialization in the tokenizer?
That might affect function matching. Maybe you could replace it with {}?
comment:5 by , 4 years ago
Fixed by 5e0fc24bb7f078c2f5446a228d5dbe455223a107
The a() is simplified to (int *)0
comment:6 by , 4 years ago
| Milestone: | → 2.9 |
|---|---|
| Resolution: | → fixed |
| Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
what does it do.. does it declare a nameless parameter that is initialized with a value? is it logically equivalent with
void b(a)?can we just remove the redundant initialization in the tokenizer?