constants are ints. So b << 8
is a uint8_t and a int16_t together. The bigger one is int16_t, so the compiler promotes the other to that.
When b
is an unsigned long
, that is bigger, so the constant is promoted to that.
I would say it's one of the more annoying features of C -- you could say it's a "standards" bug rather than a compiler bug