The attached preprocessed source when compiled with -D_GLIBCXX_DEBUG encounters a runtime assert at the final call to splice. According to http://www.sgi.com/tech/stl/List.html, all iterators remain valid after a merge operation. I believe that libstdc++ is not updating the _M_sequence members of the safe iterators merged into list1.
I've also attached unpreprocessed source with comments indicating the problem. To reproduce the problem: % g++ -D_GLIBCXX_DEBUG list.ii % ./a.out /usr/include/c++/4.2/debug/list:350:error: attempt to splice an iterator from a different container. Objects involved in the operation: iterator "__i" @ 0x0xbfd5ea30 { type = N11__gnu_debug14_Safe_iteratorINSt6__norm14_List_iteratorIiEENSt7__debug4listIiSaIiEEEEE (mutable iterator); state = dereferenceable; references sequence with type `NSt7__debug4listIiSaIiEEE' @ 0x0xbfd5ea30 } sequence "__x" @ 0x0xbfd5e9c4 { type = NSt7__debug4listIiSaIiEEE; } Aborted -- Summary: GLIBCXX_DEBUG: list::merge triggers bad assert Product: gcc Version: 4.2.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: greened at obbligato dot org GCC build triplet: i486-linux-gnu GCC host triplet: i486-linux-gnu GCC target triplet: i486-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35969