Comment by Asooka
3 years ago
Or you know, just turn off UB. I don't know why C still has this, it was useful when we had truly exotic architectures with sign bits &c, but these days it is doing way more harm than good.
3 years ago
Or you know, just turn off UB. I don't know why C still has this, it was useful when we had truly exotic architectures with sign bits &c, but these days it is doing way more harm than good.
> Or you know, just turn off UB.
You cannot “turn off UB”. The behaviour is undefined in the standard, and nothing the compiler can do will make it defined. There is a profound misunderstanding of what undefined behaviour is in a lot of the comments. It is not a compiler setting. The way to make it defined is to change the standard.
Right, UB is essential part of C and can't be turned off. But it's entirely possible to turn off integer overflow UB by compiling with -fno-strict-overflow, and you should use it.
> Or you know, just turn off UB
I'm sure you will be willing to write the GCC PR that implements the required, surely trivial, analysis.
It is already implemented: -fno-strict-overflow.
For this specific kind of UB yes. I thought parent meant all UB in general.