False-positive occurs when sizeof() is used in for loop to initialize a buffer.
(warning) Uninitialized variable: buffer [uninitvar]
unsigned8 buffer[8]; unsigned32 u32, sum = 0; for(u32 = 0; u32 < sizeof(buffer); u32++) { buffer[u32] = u32; } for(u32=0; u32 < sizeof(buffer); u32++) { sum += buffer[u32]; }
Thanks for reporting, I've added your example to this ticket: https://trac.cppcheck.net/ticket/11305
It's a different issue after all. The warning disappears if the type definition is visible. e.g. with typedef unsigned char unsigned8;.
typedef unsigned char unsigned8;
Interesting. I included the header file that has the typedef. Is there any way to debug why the header information is not being loaded for the c file?
I included the header file with the -I and the problem is resolved. thanks.
Log in to post a comment.
False-positive occurs when sizeof() is used in for loop to initialize a buffer.
(warning) Uninitialized variable: buffer [uninitvar]
Thanks for reporting, I've added your example to this ticket: https://trac.cppcheck.net/ticket/11305
It's a different issue after all. The warning disappears if the type definition is visible. e.g. with
typedef unsigned char unsigned8;
.Interesting. I included the header file that has the typedef. Is there any way to debug why the header information is not being loaded for the c file?
I included the header file with the -I and the problem is resolved. thanks.