3 ms·
Left shifting a large positive number is also UB. C made a lot of things undefined that would make much more sense as implementation defined.
by Dylan16807 4mo ago
Left shifting a large positive number is also UB. C made a lot of things undefined that would make much more sense as implementation defined.
- Joker_vD 4mo agoYep. Basically, if you take a signed int/long/etc. and a set bit shifts left into the sign bit — UB. > a lot of things... would make much more sense as implementation defined. Or even just defined. Apparently, the fact that shifting right a signed number is done arithmetically, not logically, is implementation-defined too. Well, at lest bitwise not/and/or are (almost) fully defined even for signed integers, so that's something.
- Dylan16807 4mo agoWell at the time it made sense not to force two's complement. But I would try harder to trim the UB list over time.