------- Comment #1 from pinskia at gmail dot com 2010-07-06 14:40 ------- Subject: Re: New: bug in STL iterator class
On Jul 6, 2010, at 7:21 AM, "andre dot bergner dot 0 at googlemail dot com" <gcc-bugzi...@gcc.gnu.org> wrote: > This is not a compiler bug, but a bug in the STL iterator class. > The less-than-operator does not work properly. > The following program can reproduce the bug. > > # include <iostream> > # include <vector> > using namespace std; > > main() { > vector<int> v; > vector<int>::iterator i = v.begin(); > --i; I think the behavior is undefined because now i is not inside the vector at all. In fact I think doing --i on an iterator at the begining is undefined. > cout << ( i - v.begin() ) << endl; // output: -1 > cout << ( i < v.begin() ) << endl; // output: 0 !!! SHOULD BE > 1 !!! > cout << ( i - v.begin() < 0) << endl; // output: 1 this one is > correct > } > > > -- > Summary: bug in STL iterator class > Product: gcc > Version: unknown > Status: UNCONFIRMED > Severity: normal > Priority: P3 > Component: c++ > AssignedTo: unassigned at gcc dot gnu dot org > ReportedBy: andre dot bergner dot 0 at googlemail dot com > GCC build triplet: - > GCC host triplet: - > GCC target triplet: - > > > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44840 > -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44840