bug report
zuchman
zuchman@epitera.com
Thu Nov 9 01:08:00 GMT 2000
Peace!
I want to report a bug in the stl iterators.
the bug is in the operator++(int), which should to return const
data or else this example code is
legal :
ÃÂ
#include <list>
#include <iostream>
using namespace std;
int main(int argc, char* argv[]){
ÃÂ list<int> l;
ÃÂ
ÃÂ l.push_back(0);
ÃÂ l.push_back(1);
ÃÂ l.push_back(30);
ÃÂ l.push_back(40);
ÃÂ l.push_back(50);
ÃÂ
ÃÂ for (list<int>::iterator i = l.begin();i != l.end(); i ++++ )
ÃÂ cout << *i << endl;
ÃÂ return 0;
}
ÃÂ
ÃÂ _Self operator++(int) {
ÃÂ ÃÂ ÃÂ _Self __tmp = *this;
ÃÂ ÃÂ ÃÂ ++*this;
ÃÂ ÃÂ ÃÂ return __tmp;
ÃÂ }
should be :
ÃÂ const ÃÂ _Self operator++(int) {
ÃÂ ÃÂ ÃÂ _Self __tmp = *this;
ÃÂ ÃÂ ÃÂ ++*this;
ÃÂ ÃÂ ÃÂ return __tmp;
ÃÂ }
ÃÂ
--ÃÂ
Horrible Zuchman :)
Epitera
03 - 7318001 (ext 319)
ÃÂ
More information about the Gcc
mailing list