Ancestors

Toot

Written by Félix on 2025-01-12 at 19:56

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

Descendants

Written by void friend on 2025-01-12 at 20:04

@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

Written by Félix on 2025-01-12 at 20:15

@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

Written by void friend on 2025-01-12 at 20:27

@fay59 isn't -std=c99 a promise too?

=> More informations about this toot | More toots from void_friend@tech.lgbt

Written by void friend on 2025-01-12 at 20:35

@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

Written by Félix on 2025-01-12 at 20:47

@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

Written by Jacques Fortier on 2025-01-12 at 20:07

@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

Written by Shafik Yaghmour on 2025-01-12 at 20:16

@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.

=> View attached media

=> More informations about this toot | More toots from shafik@hachyderm.io

Written by Félix on 2025-01-12 at 20:17

@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

Written by Shafik Yaghmour on 2025-01-12 at 23:30

@fay59 that is a sad state of affairs

=> More informations about this toot | More toots from shafik@hachyderm.io

Written by Alex Cordonnier on 2025-01-12 at 21:17

@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

Written by Félix on 2025-01-12 at 22:23

@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

Proxy Information
Original URL
gemini://mastogem.picasoft.net/thread/113817142262842338
Status Code
Success (20)
Meta
text/gemini
Capsule Response Time
345.492254 milliseconds
Gemini-to-HTML Time
2.194047 milliseconds

This content has been proxied by September (ba2dc).