public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/22591] New: std::swap() followed by list::erase() produces incorrect list::begin()
@ 2005-07-21 16:00 Simon dot Finn at reify dot co dot uk
  2005-07-21 16:12 ` [Bug c++/22591] " Simon dot Finn at reify dot co dot uk
                   ` (46 more replies)
  0 siblings, 47 replies; 49+ messages in thread
From: Simon dot Finn at reify dot co dot uk @ 2005-07-21 16:00 UTC (permalink / raw)
  To: gcc-bugs

Save the following as foo.C, then

g++ foo.C -o foo

Running foo blows the assertion.

g++ -v produces:

Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../gcc-4.0.1/configure
Thread model: posix
gcc version 4.0.1

Uncommenting the print statements shows that my_list.begin()
has not been updated by the call to my_list.erase(), even
though the first (only) element of this list has just been deleted.


//----------------------------------------------------------------------------

#include <list>
#include <iostream>
#include <cassert>

using namespace std;

main()
{
	list<int> my_list;
	my_list.push_front(1);

	list<int> my_other_list;
	my_other_list.push_front(2);

//cerr << "Lists built \n";
//cerr << "my_list.end() = " << ((void *) (&*my_list.end())) << "\n";
//cerr << "my_list.begin() = " << ((void *) (&*my_list.begin())) << "\n";
//cerr << "my_other_list.end() = " << ((void *) (&*my_other_list.end())) << "\n";
//cerr << "my_other_list.begin() = " << ((void *) (&*my_other_list.begin())) <<
"\n";

	swap(my_list,my_other_list);

//cerr << "After swap \n";
//cerr << "my_list.end() = " << ((void *) (&*my_list.end())) << "\n";
//cerr << "my_list.begin() = " << ((void *) (&*my_list.begin())) << "\n";
//cerr << "my_other_list.end() = " << ((void *) (&*my_other_list.end())) << "\n";
//cerr << "my_other_list.begin() = " << ((void *) (&*my_other_list.begin())) <<
"\n";

	list<int>::iterator it = my_list.begin();
	while (it != my_list.end())
	{
//cerr << "erasing: " << ((void *)(&*it)) << "\n";
		it = my_list.erase(it);
//cerr << "my_list.end() = " << ((void *) (&*my_list.end())) << "\n";
//cerr << "my_list.begin() = " << ((void *) (&*my_list.begin())) << "\n";
	}

//cerr << "At end \n";
//cerr << "my_list.end() = " << ((void *) (&*my_list.end())) << "\n";
//cerr << "my_list.begin() = " << ((void *) (&*my_list.begin())) << "\n";
//cerr << "my_other_list.end() = " << ((void *) (&*my_other_list.end())) << "\n";
//cerr << "my_other_list.begin() = " << ((void *) (&*my_other_list.begin())) <<
"\n";

	assert(my_list.begin() == my_list.end());
}

-- 
           Summary: std::swap() followed by list::erase() produces incorrect
                    list::begin()
           Product: gcc
           Version: 4.0.1
            Status: UNCONFIRMED
          Severity: critical
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: Simon dot Finn at reify dot co dot uk
                CC: gcc-bugs at gcc dot gnu dot org
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22591


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

end of thread, other threads:[~2005-08-03 18:26 UTC | newest]

Thread overview: 49+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-21 16:00 [Bug c++/22591] New: std::swap() followed by list::erase() produces incorrect list::begin() Simon dot Finn at reify dot co dot uk
2005-07-21 16:12 ` [Bug c++/22591] " Simon dot Finn at reify dot co dot uk
2005-07-21 16:15 ` pcarlini at suse dot de
2005-07-21 17:03 ` giovannibajo at libero dot it
2005-07-21 17:04 ` pinskia at gcc dot gnu dot org
2005-07-21 17:58 ` pinskia at gcc dot gnu dot org
2005-07-21 18:04 ` janis at gcc dot gnu dot org
2005-07-22  0:18 ` pcarlini at suse dot de
2005-07-22  1:25 ` pcarlini at suse dot de
2005-07-22  8:28 ` pcarlini at suse dot de
2005-07-22 11:19 ` [Bug c++/22591] [4.0 Regression] " pcarlini at suse dot de
2005-07-22 12:46 ` pcarlini at suse dot de
2005-07-22 16:04 ` janis at gcc dot gnu dot org
2005-07-22 16:40 ` reichelt at gcc dot gnu dot org
2005-07-22 22:24 ` janis at gcc dot gnu dot org
2005-07-22 22:30 ` pcarlini at suse dot de
2005-07-22 22:43 ` pcarlini at suse dot de
2005-07-23  1:32 ` reichelt at gcc dot gnu dot org
2005-07-23  3:22 ` reichelt at gcc dot gnu dot org
2005-07-24 16:13 ` [Bug tree-optimization/22591] " pinskia at gcc dot gnu dot org
2005-07-24 16:25 ` [Bug rtl-optimization/22591] [4.0/4.1 " pinskia at gcc dot gnu dot org
2005-07-24 16:33 ` [Bug tree-optimization/22591] " pinskia at gcc dot gnu dot org
2005-07-24 16:42 ` pinskia at gcc dot gnu dot org
2005-07-24 22:32 ` reichelt at gcc dot gnu dot org
2005-07-24 22:38 ` pinskia at gcc dot gnu dot org
2005-07-25  0:26 ` reichelt at gcc dot gnu dot org
2005-07-26 10:43 ` steven at gcc dot gnu dot org
2005-07-26 11:19 ` steven at gcc dot gnu dot org
2005-07-26 11:43 ` steven at gcc dot gnu dot org
2005-07-26 11:57 ` steven at gcc dot gnu dot org
2005-07-26 12:01 ` [Bug tree-optimization/22591] [4.0/4.1 Regression] wrong alias information causes an incorrect redundant load elimination steven at gcc dot gnu dot org
2005-07-26 13:11 ` rguenth at gcc dot gnu dot org
2005-07-26 13:28 ` pcarlini at suse dot de
2005-07-26 14:27 ` dnovillo at gcc dot gnu dot org
2005-07-26 15:15 ` dnovillo at gcc dot gnu dot org
2005-07-26 16:19 ` dnovillo at gcc dot gnu dot org
2005-07-26 19:56 ` cvs-commit at gcc dot gnu dot org
2005-07-26 20:05 ` dnovillo at gcc dot gnu dot org
2005-07-26 20:06   ` Andrew Pinski
2005-07-26 20:10 ` pinskia at physics dot uc dot edu
2005-07-26 20:44 ` steven at gcc dot gnu dot org
2005-07-26 20:51 ` [Bug tree-optimization/22591] [4.0 regression] " steven at gcc dot gnu dot org
2005-07-26 20:56 ` cvs-commit at gcc dot gnu dot org
2005-07-26 21:07 ` dnovillo at gcc dot gnu dot org
2005-07-26 22:04 ` steven at gcc dot gnu dot org
2005-07-26 23:08 ` dnovillo at redhat dot com
2005-07-27 13:25 ` redi at gcc dot gnu dot org
2005-07-27 15:13 ` Simon dot Finn at reify dot co dot uk
2005-08-03 18:26 ` cvs-commit 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).