Regarding left and right shift operators from the standard C ++ 5.8 section:
The behavior is undefined if the right operand is negative or greater than or equal to the bit length of the advanced left operand.
He then says that the left shift operator E1 <E2 leads to undefined behavior when all of the following conditions are true:
- The left operand has a signed type.
- Either the left operand has a negative value, or has a non-negative value, so that E1 Γ 2 ^ E2 is not represented in the resulting type.
Also, with respect to the right-shift operator E1 β E2, the behavior is implementation-dependent if the left operand is of subscription type and negative value.
The bitwise operators AND, XOR, and OR are well defined for all integral types. This is indicated in sections 5.11, 5.12 and 5.13, respectively.
However, we note that the representation of signed integral values ββcan be either two-component, or complementary, or symbolic. However, most compilers use the Two Supplement view. These include gcc, VC ++, icl, and Clang.
Hadi brais
source share