I have this typedef:
typedef union
{
unsigned Value;
unsigned Timestamp:16;
} BITFIELD;
and get this compiler warning:
BITFIELD bitfield;
// read from uninitialised memory - may result in unexpected behaviour
bitfield.Timestamp = 12;
Now, the warning disappears when I use a short instead of the bitfield:
typedef union
{
unsigned Value;
unsigned short Timestamp;
} DATATYPE;
I am not sure what to think about this warning - I don't understand it. There is no uninitialised memory involved and no read operation, too. IMHO the compiler (VisualDSP++ 5.0 C/C++ Compiler) is wrong here. The warning disappears also, when I use a :32
bitfield for Timestamp.
Is there anything I didn't realize? Can I safely ignore this warning?