crash while assigning std::list iterators

Giganews Newsgroups
Subject: crash while assigning std::list iterators
Posted by:  thomas.grund.19…@gmail.com
Date: Sat, 7 Mar 2015

Hello,

The following code crashes in Visual Studio 2010, but is ok with 2013. It is code which was stripped from a more complex example.
What am I doing wrong?

Thanks a lot!
Thomas

#include <list>

int main(int , char *[])
{
  std::list<int> List;
  std::list<int>::iterator I1, I2, I3;

  List.push_back(1);
  I2 = List.begin();
  I1 = I2;
  I1 = I3;
}

Replies