2 ms·
> ((i >= i) << i) UB.
by loeg 10y ago
> ((i >= i) << i)
UB.
- OMGWTF 10y agoAh, you're right. > If the value of the right operand is negative > or is greater than or equal to the width of > the promoted left operand, the behavior is > undefined" (http://www.open-std.org/jtc1/sc22/WG14/www/docs/n1570.pdf http://www.open-std.org/jtc1/sc22/WG14/www/docs/n1570.pdf - ISO/IEC 9899:201x (C11 Working Draft N1570): 6.5.7 Bitwise shift operators)
- loeg 10y agoYeah. It seems like something easy to define to me, at least in the case the compiler can recognize the shift is a constant. But that's the standard for you.