public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "redi at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/22513] New: [4.0 regression] Miscompilation of std::list code in Boost.
Date: Sat, 16 Jul 2005 19:05:00 -0000	[thread overview]
Message-ID: <20050716190121.22513.redi@gcc.gnu.org> (raw)

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


             reply	other threads:[~2005-07-16 19:01 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-07-16 19:05 redi at gcc dot gnu dot org [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050716190121.22513.redi@gcc.gnu.org \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).