http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46143
--- Comment #4 from Ryan Johnson <scovich at gmail dot com> 2010-10-22 23:06:53
UTC ---
As I said, the stack smashing was only there to make the behavior consistent.
If the offending stack location happens to contain zero, the bug would go
unnoticed (try adding 'long n[1]' as another local, for me it makes the symptom
go away unless the stack smash exposes it.
In any case, here's a minimal testcase which doesn't do anything evil:
#include <vector>
#include <cassert>
typedef std::vector<int> intv;
int
#ifdef BUG
__attribute__((optimize(0)))
#endif
main() {
intv v;
intv::iterator it = v.begin();
assert(it == v.begin());
return 0;
}