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
@johnregehr @RichFelker @ch3root @spun_off Maybe: (char *)(((uintptr_t)(p + 7) & ((uintptr_t)~UINTMAX_C(7)) is better.
@johnregehr @RichFelker @ch3root @spun_off Prerequisite: p points to an object that is at least 8 octets long.
@johnregehr @RichFelker @ch3root @spun_off But, the `&` still ruins things, if we're being pedantic. (And if we aren't, why are we here?)
@BRIAN_____ @johnregehr @RichFelker @ch3root @spun_off There's always `while((uintptr_t)p % 8) { ++p; } return p;`
@sevenps @johnregehr @RichFelker @ch3root @spun_off Isn't `%` on `uintptr_t` values undefined? e.g. if ptr <-> int cast requres ROTR/ROTL.
@BRIAN_____ @sevenps @johnregehr @ch3root @spun_off % is always defined on uint types, but any correspondence to addr arch is impl-defined.
@BRIAN_____ @sevenps @johnregehr @ch3root @spun_off If the impl-def'd (i.e. ABI-def'd) conv to uintptr_t is flat, % does what you want.
@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...
@BRIAN_____ @johnregehr @ch3root @spun_off This would force impls with advanced ptr models not to define [u]intptr_t at all.
@RichFelker @johnregehr @ch3root @spun_off I'm not sure what you mean then. Isn't that a prereq. for ptr -> uintptr_t math -> ptr?
@BRIAN_____ @johnregehr @ch3root @spun_off No. Without that you can still do all sorts of math treating the values as opaque.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.