[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

improper STL list sort iterator invalidation

From: Andy Sloane
Subject: improper STL list sort iterator invalidation
Date: Mon, 25 Nov 2002 17:14:33 -0600
User-agent: Mutt/1.3.25i

Hi there,

I'm not sure if this address is still valid, but we've found a bug, or what
we believe to be a bug, in the libg++ standard template library involving

Test code:

#include <stdio.h>
#include <list>

int main()
        list<int> x;
        list<int>::iterator i;
        i = x.end();
        if(i == x.end()) printf("i is at the end()\n");
        else printf("i is not at the end()\n");

Proper output is "i is at the end()", but on Red Hat Linux gcc 2.96, and
Mac OS X gcc 1151 ("based on version 3.1"), i is not at the end() after the

The problem is that sort() invalidates an iterator pointing to the end,
when the STL spec, or at least SGI's STL documentation, says it won't
invalidate any of them.

I have no idea whether this was fixed in the recent gcc 3.2.1 release, but
I just wanted to be sure someone was aware of it.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]