This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Assignment To Bit-field Doesn't Warn Of Truncation

Hello,

I'm interested to know why the compiler doesn't let warn me that truncation will occur if an assigned value is too big for a bit-field. I have the following bit-field:

struct packed_tag {
     uint32_t lower_word:16;
     uint32_t higher_word:16;
}pack0;

I only get "#70-D: integer conversion resulted in truncation" on the first line of the following code, not the second. Why is that please?

    uint16_t my_uint = 0x10000U;
    pack0.lower_word = 0x10000U;

Thank you.