http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46143
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> 2010-10-22 22:47:09 UTC --- that program has two kinds of undefined behaviour I can see not only do two wrongs not make a right, but attribute((optimize(0))) doesn't make it right either do you have a testcase that doesn't rely on dereferencing a non-dereferenceable iterator?