The above code uses (or tries to use) a non-const iterator to create a non-sorted set. The code would compile in Visual Studio but not using gcc, for which set::iterator is defined as set::const_iterator to avoid this kind of (ab)use.

Although there are other ways to obtain unsorted sets (e.g. through custom comparison operators or external non-const references/pointers to the elements), my tip is to avoid the use of stl set non-const iterators whenever possible.