I created the following file and named it "t.c":
unsigned short f(void) { unsigned short const int x = 1; return x; }
Then I ran the following command with cppcheck 2.4.1:
cppcheck t.c --enable=style --debug
The result claims wrongly that x is not assigned to:
Checking t.c ... ##file t.c 1: unsigned short f ( ) 2: { 3: const unsigned short x@var1 ; int x@var1 1 ; 4: return x@var1 ; 5: } ##Value flow Line 3 1 always 1 t.c:3:30: style: Variable 'x' is not assigned a value. [unassignedVariable] unsigned short const int x = 1; ^
When I move "const" to any other place in the declaration, the warning disappears.
Thanks! I can reproduce. That looks strange.
Fixed by 3c3435dd10943668a9d323f5b5b33f995f9e9d4b
Log in to post a comment.
I created the following file and named it "t.c":
Then I ran the following command with cppcheck 2.4.1:
The result claims wrongly that x is not assigned to:
When I move "const" to any other place in the declaration, the warning disappears.
Thanks! I can reproduce. That looks strange.
Fixed by 3c3435dd10943668a9d323f5b5b33f995f9e9d4b