This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/44840] New: bug in STL iterator class
- From: "andre dot bergner dot 0 at googlemail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 6 Jul 2010 14:21:19 -0000
- Subject: [Bug c++/44840] New: bug in STL iterator class
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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;
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