The program goto endless loops when run erase() in a for loop,as fallows: #include <map> #include <stdio.h> std::map<int , int> mymap; int main() { mymap[2] =3 ; mymap[1] = 4; printf("**********test map.erase*********\n"); std::map<int,int>::iterator it; it = mymap.begin(); for (; it != mymap.end() ; it++) { mymap.erase((*it).first); } return 0; }
I have try to delete the line "printf("**********test map.erase*********\n");",then it worked correctly! The configure string is : ./configure --prefix=/usr/local/gcc-4.2.0 --program-suffix=-420 --enable-language=c,c++ -- Summary: std::map.erase on cygwin Product: gcc Version: 4.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: lifelong830114 at gmail dot com GCC build triplet: i686-pc-cygwin GCC host triplet: i686-pc-cygwin GCC target triplet: i686-pc-cygwin http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41480