b94
If you plan to use gcov to help optimize your code, you must first compile your program with two options: -fprofile-arcs and -ftest-coverage. Aside from that, you can use any other GNU CC options; but if you want to prove that every single line in your program was executed, you should not compile with optimization at the same time. On some machines the optimizer can eliminate some simple code lines by combining them with other lines. For example, code like the following can be compiled into one instruction on some machines.
if (a != b) c =1; else c =0;In this case, there is no way for gcov to calculate separate execution counts for each line because there isnt separate code for each line. Hence, the gcov output looks like this if you compiled the program with optimization.