Hi! We are bumping from GCC 7.5.0 to GCC 9.4.0 (Ubuntu 20.04) and observe that GCOV is stuck when analyzing the following minimal repro code: #include <vector> #include <array> template <typename T, std::size_t n> class StaticVector { public: StaticVector() = default; void foo(){} private: std::array<T, n> data{}; }; class Foo { StaticVector<std::vector<std::size_t>, 40000> data_{}; }; int main() { Foo f; return 0; } $ g++ --coverage main.cpp $ ./a.out $ gcov main.cpp The problem goes away if I remove the value initialization for std::array in the StaticVector class (i.e. I leave the member "data" uninitialized). The same problem happens also on GCC 11 What might be the reason for this? Thanks!
On the trunk it takes no time at all: [apinski@xeond2 upstream-gcc-git]$ ~/upstream-gcc/bin/g++ t.cc --coverage [apinski@xeond2 upstream-gcc-git]$ LD_LIBRARY_PATH=~/upstream-gcc/lib64 ./a.out [apinski@xeond2 upstream-gcc-git]$ LD_LIBRARY_PATH=~/upstream-gcc/lib64 ~/upstream-gcc/bin/gcov t.cc t.gcno:cannot open notes file t.gcda:cannot open data file, assuming not executed No executable lines [apinski@xeond2 upstream-gcc-git]$ LD_LIBRARY_PATH=~/upstream-gcc/lib64 ~/upstream-gcc/bin/gcov a-t.cc File '/home/apinski/upstream-gcc/include/c++/14.0.0/bits/stl_construct.h' Lines executed:100.00% of 4 Creating 'stl_construct.h.gcov' File '/home/apinski/upstream-gcc/include/c++/14.0.0/bits/new_allocator.h' Lines executed:50.00% of 4 Creating 'new_allocator.h.gcov' File '/home/apinski/upstream-gcc/include/c++/14.0.0/bits/stl_vector.h' Lines executed:95.45% of 22 Creating 'stl_vector.h.gcov' File '/home/apinski/upstream-gcc/include/c++/14.0.0/bits/alloc_traits.h' Lines executed:66.67% of 3 Creating 'alloc_traits.h.gcov' File '/home/apinski/upstream-gcc/include/c++/14.0.0/bits/allocator.h' Lines executed:100.00% of 1 Creating 'allocator.h.gcov' File 't.cc' Lines executed:100.00% of 5 Creating 't.cc.gcov' File '/home/apinski/upstream-gcc/include/c++/14.0.0/array' No executable lines Removing 'array.gcov' Lines executed:89.74% of 39 real 0m0.043s user 0m0.004s sys 0m0.002s
Fixed in GCC 12.1.0 by the same patch which fixed PR 92385 .
Note it is not an infinite loop, just many basic blocks (over 40000 of them) causing the performance to be very very slow.