Корректен ли такой код, если нужно склеить 2 байта:
unsigned char a = 0xAA;
unsigned char b = 0xFF;
unsigned short c = (a<<8)|b;
Стандарт:
3 The integer promotions are performed on each of the operands. The type of the result is that of the promoted left operand. If the value of the right operand is negative ori s greater than or equal to the width of the promoted left operand, the behavior is undefined.
Как я понял, перед сдвигом имеет место приведение типа обоих операндов. Соответственно, результат (a<<8) уже не однобайтовый и дает 0xAA00. Если так, к какому типу приводится? От чего это зависит?