This warning seems incorrect in this case:
#include "stdio.h"
union act_val{
double a;
int b;
};
void thing2(union act_val av)
{
printf("%d\n", av.b);
}
int main(int argc, char const *argv[])
{
union act_val av;
av.b = 1;
thing2(av);
return 0;
}
Variable av is uninitialized when used here, at the thing2 call. The warning goes away if the 'a' field is an 'int'. I suppose it is warning me that not all the bytes of the union are being initialised, as double is larger than int here. It seems like half the reason for a union is to be able to deal with a specific field at a time.
Of course I can work around the warning by initialising the 'a' field, I do not like the initialise variables with false values however as it stops genuine warnings and valgrind errors.