After the second vector v resize operation the memory for its storage may be allocated starting from the new address, so there is no guarantee that the iterator that is stored in the i variable points to the correct memory area. Runtime error is possible / undefined behavior.
Login in to like
Login in to comment