public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/22513] New: [4.0 regression] Miscompilation of std::list code in Boost.
@ 2005-07-16 19:05 redi at gcc dot gnu dot org
  2005-07-16 19:15 ` [Bug c++/22513] " redi at gcc dot gnu dot org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: redi at gcc dot gnu dot org @ 2005-07-16 19:05 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2005-07-27 13:25 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-16 19:05 [Bug c++/22513] New: [4.0 regression] Miscompilation of std::list code in Boost redi at gcc dot gnu dot org
2005-07-16 19:15 ` [Bug c++/22513] " redi at gcc dot gnu dot org
2005-07-16 19:42 ` giovannibajo at libero dot it
2005-07-16 19:47 ` pinskia at gcc dot gnu dot org
2005-07-17 10:46 ` redi at gcc dot gnu dot org
2005-07-17 11:12 ` redi at gcc dot gnu dot org
2005-07-19 13:53 ` redi at gcc dot gnu dot org
2005-07-27  9:02 ` reichelt at gcc dot gnu dot org
2005-07-27 12:25 ` redi at gcc dot gnu dot org
2005-07-27 12:26 ` reichelt at gcc dot gnu dot org
2005-07-27 12:53 ` redi at gcc dot gnu dot org
2005-07-27 13:27 ` redi at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).