string iterator problem

I'm experimenting with string class and iterators, and am getting a warning that I don't understand. Here is the program:

#include <cstdio>
#include <string>
using namespace std;

int main(void)
{
string my_str("abcdefghijklmnopqrstuvwxyz") ;
printf("testing string iterator: ") ;
string::iterator stidx ;
for (stidx=my_str.begin(); stidx != my_str.end(); stidx++) {
printf("%c", *stidx) ;
}
puts("") ;

return 0;
}

I am using MinGW to build. If I compile with just -Wall, it compiles clean, and it runs with expected output.
However, if I use -Weffc++, I get several incomprehensible warnings, as shown below. I presume I am declaring the iterator not quite right somehow, but I don't know what is wrong.

Any insights would be gratefully received!!

c:\sourcecode\cplusplus Yes, Master?? > g++ -Wall -O2 -Weffc++ -s strings.cpp -o strings.exe
c:/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_iterator.h: In instantiation of `__gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >':
strings.cpp:12: instantiated from here
c:/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_iterator.h:587: warning: `class __gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >' has pointer data members
c:/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_iterator.h:587: warning: but does not override `__gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >(const __gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >&)'
c:/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_iterator.h:587: warning: or `operator=(const __gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >&)'
Heh... I figured out the answer to this... I've been using an older version of MinGW:
g++ (GCC) 3.4.5 (mingw special)
and it apparently has a minor bug in string iterators (minor in that -Wall did not flag it, but -Weffc++ did). I was avoiding upgrading to current code because it generates significantly larger code, but now for the first time, I have a reason to!

Decided to leave this post here, with the solution, in case someone else stumbles over a similar issue...
You should mark the problem as solved now
Topic archived. No new replies allowed.