This is similar to #59659, but is still a problem in GCC 11.2.1 and GCC 10.2.1. The following code takes a very long time to compile with -O3 enabled: #include <vector> #ifndef SIZE #define SIZE 100000 #endif struct S { int a; }; struct T { std::vector<S> arr[SIZE]{}; // remove the default-initializer {} to compile fast }; int main(int argc, char** argv) { T t; for (int i=0; i<SIZE; ++i) { t.arr[i].push_back(S{argc * i}); // use argc so that gcc doesn't optimize everything out } return t.arr[SIZE-1][0].a; }
Looks to be fixed with GCC 12.1.0 .
Dup of bug 92385. *** This bug has been marked as a duplicate of bug 92385 ***