A Boost regression test has been failing for some time with GCC 4.0.x although it works with GCC 3.4, mainline and several other compilers that run the Boost tests.
The problem seems to be that a std::list element is not removed correctly, causing it to be removed twice and crashing on the second attempt. I think a list node might have a dangling pointer but haven't figured it out yet. Creating pre-processed source with mainline and compiling with 4.0 still causes the bug, pre-processing with 4.0 and compiling with 4.1 doesn't, so it's not a libstdc++ problem. The attached .ii file was produced by gcc version 4.0.2 20050716 (prerelease) from the following code, using the latest ptr_list from Boost's CVS. Sorry about the size of the .ii, the ptr_list brings in a lot of code. #include <iterator> #include <cassert> #include <boost/ptr_container/ptr_list.hpp> struct B { virtual ~B() {} }; struct T : public B {}; int main() { typedef boost::ptr_list<B> C; C c; assert( c.size() == 0 ); c.push_back( new T ); assert( c.size() == 1 ); C c3( c.begin(), c.end() ); assert( c.size() == c3.size() ); c.assign( c3.begin(), c3.end() ); assert( c.size() == c3.size() ); c.erase( c.begin() ); assert( c.size() != c3.size() ); c.clear(); } This segfaults on the final line when clearing the container. (Or if mainline is used to produce a .ii which is then compiled with 4.0, then the assertion on the previous line fails instead.) -- Summary: [4.0 regression] Miscompilation of std::list code in Boost. Product: gcc Version: 4.0.2 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: redi at gcc dot gnu dot org CC: gcc-bugs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22513