The following false-positive occurs when using multiple structs in the same union:
(style) Variable 'm.u16.ab' is reassigned a value before the old one has been used. [redundantAssignment]
/* Fixed-point math union */
typedefunionfixed32_union{struct{unsigned32abcd;}u32;struct{unsigned16ab;unsigned16cd;}u16;struct{unsigned8a;unsigned8b;unsigned8c;unsigned8d;}u8;}fixed32;
voidfunc1(void){fixed32m;m.u16.ab=47;m.u16.cd=0;m.u16.ab=m.u32.abcd/53;}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The following false-positive occurs when using multiple structs in the same union:
(style) Variable 'm.u16.ab' is reassigned a value before the old one has been used. [redundantAssignment]
Thanks for reporting, I've added your example to this ticket: https://trac.cppcheck.net/ticket/10093