quick quiz! which are incorrect and why cc @spun_offpic.twitter.com/swiTYVVMmb
You can add location information to your Tweets, such as your city or precise location, from the web and via third-party applications. You always have the option to delete your Tweet location history. Learn more
@RichFelker @ch3root @spun_off which non-2's complement platforms does musl support?
@johnregehr @RichFelker @ch3root @spun_off The C standard guarantees pointer -> [u]intptr_t -> pointer round trips. However...
@johnregehr @RichFelker @ch3root @spun_off ...it doesn't guarantee anything if you do any math on the [u]intptr_t value in the middle.
@BRIAN_____ @johnregehr @ch3root @spun_off If you do math on the uintptr_t and get back a uintptr_t you got from converting a pointer...
@BRIAN_____ @johnregehr @ch3root @spun_off ...then you are certainly justified in converting it back to a pointer.
@RichFelker @johnregehr @ch3root @spun_off Justified by what? It would be nice but I don't think there's any guarantee.
@BRIAN_____ @johnregehr @ch3root @spun_off Because it's the same value, and C guarantees round-trip of pointers through uintptr_t.
@RichFelker @johnregehr @ch3root @spun_off I think the C std should say that arithmetic on uint8_t* is equiv to arith on uintptr_t reps...
@RichFelker you are ruining @johnregehr's fun
@spun_off @johnregehr The best, cleanest form is: p += (-(uintptr_t)p & 7)
@RichFelker C interpreters that manipulate symbolic representations agree to disagree with you about the cleanliness of that last one.
@RichFelker The results of all intermediate expressions in past examples could be encoded as base_address + offset. Not so for -(uintptr_t)p
@spun_off Mine is the only one where the compiler can legitimately assume rules of pointer arithmetic hold (because it's ptr arith.).
@spun_off The other forms all do the arithmetic as a uint type where any operation is well-defined. Final ptr may point to different object.
@spun_off In this specific case, the offset is bounded [0,7] and the compiler can deduce that it's still in the same object, tho.
@johnregehr @ch3root @spun_off The correct portable replacement for ~7 is -8.
@RichFelker @johnregehr @ch3root @spun_off Can't tell if trolling; the only reason for the sign is sign extension. -8 in 1's comp. is wrong.
@UINT_MIN On a 1's complement machine, conversion signed->unsigned does not simply reuse the bits. It can't because it has to follow std.
@spun_off @RichFelker Ooops. Right, conversions happen on values, not representations. Sorry!
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.