http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46143
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> 2010-10-22 22:53:17 UTC --- here's one which avoids invalid iterators and stack smashing: #include <cassert> #include <vector> struct foo { }; typedef std::vector<foo*> foov; foov v(1); int #ifdef BUG __attribute__((optimize(0))) #endif main() { foov::iterator it = v.begin(); assert( &*it == &v.front() ); return 0; }