I think it's a bit unfortunate that the OP chose p + 1 - 1 as an example because p + 1 is not undefined behavior as shown in Vlad from Moscow's answer.
The question is more interesting if we consider p + 2 - 2. Here p + 2 is indeed undefined behavior. But does that matter if in the full expression we "undo this computation".
There is an analog for integers. E.g. given i a signed integer and if i + 2 overflows, thus being undefined behavior, is the expression i + 2 - 2 ok or undefined behavior?
The answer to both is that it is undefined behavior. If an expression is undefined behavior and the program would reach that expression in its evaluation then the whole program exhibits undefined behavior.
There is a more know case about this: computing the mid point of signed integers: (a + b) / 2 is UB if a + b overflows, even if the the final value would fit in the data type.
*pis not UB.p + 1is a pointer to a memory that is not owned by x, but is not an undefined behavior. There is the exception forp + 1in C++ standard.p + 1after the allocated memory is ok unless you dereference it.p + nif n >= 1 as impossible, otherwise it would result in UB, and may apply any optimizations assuming n <= 1.