Losing the magic
Losing the magic
Posted Dec 6, 2022 22:45 UTC (Tue) by khim (subscriber, #9252)In reply to: Losing the magic by Wol
Parent article: Losing the magic
> IF THE HARDWARE HAS UBs (those were your own words!)
Not if. Hardware most definitely have an UB. x86 have less UBs than most other architectures, but it, too can provide mathematically impossible results!
On the hardware level, without help from the compiler! If used incorrectly, of course.
These UBs are results of hardware optimizations, instead. You can not turn these off!
But you can find series of articles which are explaining how one is supposed to work with all that right here, on LWN!
You have probably seen then already, but probably haven't realized what they are actually covering.
> if the compiler assumes that there is no UB, then we're screwed ...Why? How? What suddenly happened? Compiler deals with these UBs precisely and exactly like with any other UBs: it assumes they never happen.
And then programmer is supposed to deal with all that in the exact same fashion as with any other UBs: by ensuring that compiler assertion is correct.
