Aren't they trying to patch this to not be UB in most cases with http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1457 … ?
-
-
-
Yes, looking at the latest C++20 draft they have changed it to be two's complement rather than UB.
- 1 more reply
New conversation -
-
-
I didn't actually know the full answer: Current standard C (C18) and C++ (C++17) both agree this is UB. The C++20 draft has it as -2. The current C2x draft still has it as UB.
- 1 more reply
New conversation -
-
I'm not certain, but I guessed implementation defined. Neither C not C++ defines integers to be represented by two's complement, and I'm not sure if any of the other allowable formats would produce the same result. That said I'm not sure what arithmetic shift implies either.
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
I’d guess 1, with zero confidence, assuming that << is wrapping, 0 if it isn’t, assuming in both cases that << operate on the sign bit which sounds wrong when I say it so
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
C ( 1970 - 50 years ), C++ ( 1983 - 35 years ). Operations over unsigned and signed primitives still UB and error-prone. Shame. Although, we have a lot of fast stuff written...
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.