Question.7
A developer packs a 3-bit priority field (bits 4–6) into a control register. He writes:
reg |= (priority << 4);
If priority is 9 (which exceeds the 3-bit maximum of 7), what happens to the register?
priority
9
Select Answer
Only the lower 3 bits of 9 (i.e., 1) are placed into bits 4–6
The value 9 is placed into bits 4–6, and bit 7 is also corrupted
The compiler clamps the value to 7 automatically
Undefined behavior — the result is unpredictable