On a lot of arrays, I get this warning:
warning GC59630F4: c2012-9.3 MISRA: Required Arrays shall not be partially initialized [misra-c2012-9.3]
Here's an example of such an array:
It might be false positives. However I can't say for sure I fail to reproduce. A small example code that would reproduce the warning would be appreciated.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I was able to reproduce it by creating a typedef of a self referencing struct in a seperate header.
Creating an array of this type causes the error to come up.
When I comment out the reference to self, the error goes away.
Thank you. I can reproduce. I believe this is a false positive. In my opinion your code is compliant. I have created this ticket: https://trac.cppcheck.net/ticket/11707
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi
On a lot of arrays, I get this warning:
warning GC59630F4: c2012-9.3 MISRA: Required Arrays shall not be partially initialized [misra-c2012-9.3]
Here's an example of such an array:
static t_sensor const * apAllFastHspSensors[] =
{
// #BEGIN_SENSORS
/DEFINE_LIST_CAST (t_sensor const)((void const)/
(t_sensor const)((void const)&entry1),
(t_sensor const)((void const)&entry2),
(t_sensor const)((void const)&entry3),
(t_sensor const)((void const)&entry4),
(t_sensor const)((void const)&entry5),
// #END_SENSORS
(t_sensor const *)(NULL),
};
t_sensor is a typedef of a struct.
I checked by removing the casting and it doesn't change much.
Any advice?
Thanks!
It might be false positives. However I can't say for sure I fail to reproduce. A small example code that would reproduce the warning would be appreciated.
Hi,
I was able to reproduce it by creating a typedef of a self referencing struct in a seperate header.
Creating an array of this type causes the error to come up.
When I comment out the reference to self, the error goes away.
How would I fix this?
This code in a different source file then throws the error:
Thank you. I can reproduce. I believe this is a false positive. In my opinion your code is compliant. I have created this ticket:
https://trac.cppcheck.net/ticket/11707
Thanks :)
I have made a fix.
https://github.com/danmar/cppcheck/commit/4cf9a704b4b87ce7387c327705199bd9713c7ee9
If you can test it feel free to ..
Awesome!
It didn't work at first, but after I removed the cppcheck build output for the offending file the error was gone. Great support, thanks!