Re:Defining the Undefinedness of C (2015) [pdf]
by adrianratnapala on Thursday July 27, 2017 @12:49AM
(#14862786)
Right, but it is not the plus operation that does this. You can reserve undefined behaviour to things like "write to a bad pointer".
Then a particular ABI could say "if your pointer overflows (by a our system specific meaning of overlow) then you have a bad pointer". Merely doing a pointer increment just gets you implementation-defined behaviour. The UB only happens if you plough on.
Such a setup wouldn't do much to save us from pointer bugs. But it would make optimizers more predictable.
Then a particular ABI could say "if your pointer overflows (by a our system specific meaning of overlow) then you have a bad pointer". Merely doing a pointer increment just gets you implementation-defined behaviour. The UB only happens if you plough on.
Such a setup wouldn't do much to save us from pointer bugs. But it would make optimizers more predictable.