What is the result of assigning to std::vector<T>::begin()?
v.begin() is an iterator. Assigning to an iterator does not assign to the value the iterator points to. In addition, because
v.begin() is a prvalue, the object that you are assigning to gets destroyed at the end of the line, without affecting
v or any of the "permanent" memory it owns.
If v.begin() were a raw pointer, the compiler would issue an error for trying to assign to an rvalue. However, the type std::vector::iterator is often a class type, and it seems that this is the case on your implementation (with the specific set of compiler flags you are using), so assigning to v.begin() calls the operator= of that class type. But that doesn't change the fact that the iterator object is a temporary object, and assigning to it has no further effects.
In order to assign to the element that v.begin() points to, you need to dereference it: *v.begin() = *(v.end() - 2)