I see reports that ((int64_t)x >> 63) is undefined behaviour in C. Ok. Fine. Is there an equivalent that is somehow “defined”? I expect my hardware to use 2-complement. // cc @johnregehr
-
-
cppcheck gives me the following ... see screenshot. My question is… what do I do now if I want to be a good boy. Do I write my own assembly (not hard, but…).pic.twitter.com/kjsNQRioFw
-
Hmm... I would *guess* that 63 isn't a problem at all, only the fact that the lhs is signed is an issue. You could do something like ~(((uint64_t)x >> 63) - 1) and hope the compiler can optimize it. (Untested code as I am on my phone right now. So no guarantees. :)
- Show replies
New conversation -
-
-
This Tweet is unavailable.
-
For xbitmanip I use C code to formally define the behavior of instructions. For that I'm trying to avoiding implementation defined behavior for obvious reasons.pic.twitter.com/29Wn5baIzT
End of conversation
-
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.