News for hackers. Stuff that matters.
Re:Catch-23: The New C Standard Sets the World on Fire by mafuy on Sunday April 02, 2023 @08:50AM (#35409985)
> you’d have to insert a check every time you add two signed integers together,

This is exactly what is done in serious code. It is typically combined with contracts and static analysis (often human), e.g. "it is guaranteed that this input is in range 10-20, so adding it with this other 16 bit int can be assumed to be below sint32_max".

Re:Catch-23: The New C Standard Sets the World on Fire by pclmulqdq on Sunday April 02, 2023 @11:06AM (#35411265)
Great, those checks can stay in "serious" code, and those of us who don't want them can take the UB. C++ 20 actually ended up specifying that all ints are twos complement, removing this from the category of "UB," but a lot more weird stuff is programmed in C.
Re:Catch-23: The New C Standard Sets the World on Fire by gpderetta on Sunday April 02, 2023 @01:46PM (#35413139)
Note that signed overflow is still UB in c++ even with 2-complement being guaranteed for signed types.