Yesterday (at least) 8 of you learned that INT_MIN/-1 signed-integer-overflows
https://tech.lgbt/@fay59/113807449673594867
=> More informations about this toot | More toots from fay59@tech.lgbt
@fay59
fun fact 1: you can -fwrapv and it still traps
fun fact 2: you can -std=c99 and INT_MIN%-1 still traps too
=> More informations about this toot | More toots from void_friend@tech.lgbt
@void_friend fun fact 1 seems like a -fwrapv bug. It’s an x86-ism that division overflow traps (ARM CPUs don’t) that is enabled by signed integer overflow being UB, the compiler isn’t doing its job properly if it promises it’s not UB and it still traps
=> More informations about this toot | More toots from fay59@tech.lgbt
@fay59 isn't -std=c99 a promise too?
=> More informations about this toot | More toots from void_friend@tech.lgbt
@fay59 i can report it and blame Félix for fun, but what are they going to do, make it so with -fwrapv INT_MiN/-1 doesn't trap but % still does because it doesn't even wraparound? They don't want to fix it and they won't.
=> More informations about this toot | More toots from void_friend@tech.lgbt
@void_friend possibly! I don’t know what C99 says about this off the top of my head
=> More informations about this toot | More toots from fay59@tech.lgbt
@fay59 I’m told that, after I handled that corner case on a “please implement integer division on a platform that doesn’t have that instruction” question, my interviewer went back to his desk and fixed his code.
=> More informations about this toot | More toots from jacquesf@mastodon.social
@fay59
Note, tooting my own horn here but if you had previously read my "Exploring Undefined Behavior Using Constexpr" you would have known this: https://shafik.github.io/c++/undefined%20behavior/2019/05/11/explporing_undefined_behavior_using_constexpr.html
Amongst many other interesting examples.
=> More informations about this toot | More toots from shafik@hachyderm.io
@shafik unfortunately my miscreant followers are not all up to date with your writing
=> More informations about this toot | More toots from fay59@tech.lgbt
@fay59 that is a sad state of affairs
=> More informations about this toot | More toots from shafik@hachyderm.io
@fay59 whenever I see an esoteric C poll, it’s safe to assume it’s a trick question. Can we have some nice defined behavior sometimes? 😛 On second thought, that’s probably too much to ask of C.
=> More informations about this toot | More toots from alexjcord@infosec.exchange
@alexjcord yeah, it’s an artifact of the format that it works out this way. It’s hard to do better with multiple-choice questions
=> More informations about this toot | More toots from fay59@tech.lgbt This content has been proxied by September (ba2dc).Proxy Information
text/gemini