This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/44840] New: bug in STL iterator class


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]