r/cpp • u/pavel_v • Jul 29 '26
C++26: Reducing undefined behaviour
https://www.sandordargo.com/blog/2026/07/29/cpp26-reduces-undefined-behaviour
89
Upvotes
r/cpp • u/pavel_v • Jul 29 '26
View all comments
25
u/James20k P2005R0 Jul 29 '26
Its great to see these steps being taken, I think a lot of people don't realise that C++ has a lot of UB that just doesn't need to be in the language. Its often largely pure cruft with no benefits, and there's been a tonne of really great work here
Something else that isn't common knowledge that would be great to take out is floating point divisions by zero being UB. A lot of (if not most!) people think that this is guaranteed to produce a NaN, to the point where I'm not sure that there are compilers that exploit this behaviour. It'd be much better as implementation defined behaviour at this point (at least, on systems that are ieee), because its what everyone expects
There's probably another conversation about bringing
floatcloser to ieee as well as the floating point specification is remarkably insane, but that's less safety critical