https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96919
--- Comment #9 from Bhavana Kilambi <bhavana.kilambi at blackfigtech dot com> --- Hi, The problem seems to be with the code in add_line_counts() function in gcov.c. Specifically with this statement - line->blocks.push_back (block); This line is present inside the line!= NULL condition while in gcc7 it is within the flag_all_blocks condition. Since all the lines in the function satisfy the condition of line != NULL, this push_back() function gets executed almost everytime. Also, looking at the way the tool is built, initially the relevant data structures would have already been created and in place in the process_file() and other functions while the generate_results() function (which in turn calls add_line_counts() function) is supposed to technically only read/traverse the appropriate data structures and update the coverage information. After removing the above line, the coverage for the testcase in this bug is 100% as required with the -a and -m flags. Also, tested the testcase mentioned in bug #79891. It also shows the expected coverage output. I have attached the patch in this bug. Output after the patch for the testcase specified in this bug : gcov main.cpp -a File 'hello.h' Lines executed:0.00% of 2 Creating 'hello.h.gcov' File 'main.cpp' Lines executed:100.00% of 4 Creating 'main.cpp.gcov' Lines executed:66.67% of 6