https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86871
--- Comment #1 from Sergei Trofimovich <slyfox at inbox dot ru> --- Managed to get rid of templates. Looks like use of uninitialized 'i' is somehow the culprit: int *f; struct g { g() { f = new int; aj = f; } int &operator[](int h) { return *(aj + h); } int *aj; }; void j() { g b; g c; for (int i; i; i++) { int d = 0; for (int e = -1; e <= 1; e++) { int a = i + e; if (a) d = b[a]; } c[i] = d; } }