>> uint8_t gets promoted to a signed int when shifting, which in turn causes undefined behavior for specific input.
>> One way of fixing this is casting to the desired type before the shift, thus avoiding surprising conversions.
Agree. For clarity, the "specific input" in the example would be a bytes[0] value larger than 127.
This behavior is also explained here:
https://wiki.sei.cmu.edu/confluence/display/c/INT34-C.+Do+no...