Fox example:
int* a = new int[10];
int* b = a;
int* e = a + 10;
delete[] a;
for (; b != e; ++b);
I know dereferencing invalid pointer would be UB. But how about just compare and increment?
Background
Here's a question, OP's adding elements inside a range-based for loop, which might cause the iterator become invalid. But he's adding elements to the vector in the end, after that the iterator'll be increased and compared, no dereference. Is it UB?