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
Show parent comment
4
u/eisenwave WG21 Member Jul 30 '26
I think you mean that people assume it prodoces infinity. At least dividing a finite number by zero gives you infinities in practice.
Specifying that in the standard is quite tricky because any statement made about floating-point types needs to apply universally to every possible floating-point format, and there are lots of those floating around.
The solution is most likely going to be very similar to C's Annex F, where implementations optionally adhere to the behavior for ISO/IEC 60559 types there, and if they do, you get the division by zero you expect. The non-Annex-F case is probably going to be implementation-defined at best, but UB is surprisingly appropriate for it.