https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118721

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
That is not the scope of ubsan.
To diagnose this generally (unless forward propagation etc. makes it clear out
of bounds) you really need object known object boundaries for that.
So it is more like a variant of -fsanitize=pointer-subtract, except that it
wouldn't be checking the case where people do ptr1 - ptr2 in the source, but
would check on pointer arithmetics the old vs. new value.  Bet it would be
really expensive and would need libasan support (so that it doesn't mislead
people that there is a problem with pointer subtraction but with pointer
arithmetics).

Reply via email to