Considering the following fortran code: === begin code === program main
implicit none integer :: a = 7 if( a == 0 ) then print *, "a is null" else if( a > 0 ) then print *, "a is positif" else print *, "a is negatif" end if end program === end code === compiled with the "-fprofile-arcs -ftest-coverage" option flags, linked with the same flags, with gfortran-4.3.4 or gfortran-4.4.1 After a single execution, the profile file is built as usual with: $ gcov main The resulting profile is then: $ cat main.f90.gcov -: 0:Source:main.f90 -: 0:Graph:main.gcno -: 0:Data:main.gcda -: 0:Runs:1 -: 0:Programs:1 1: 1:program main -: 2: -: 3: implicit none -: 4: -: 5: integer :: a = 7 -: 6: 3: 7: if( a == 0 ) then #####: 8: print *, "a is null" -: 9: else if( a > 0 ) then 1: 10: print *, "a is positif" -: 11: else #####: 12: print *, "a is negatif" -: 13: end if -: 14: -: 15:end program First remark: line 7 is marked '3' instead of '1' Second remark: line 9 is discarded (marked '-') instead of '1' When using the current snapshot of gfortran-4.5 (2009-09-15), the result is slightly different: $ cat main.f90.gcov -: 0:Source:main.f90 -: 0:Graph:main.gcno -: 0:Data:main.gcda -: 0:Runs:1 -: 0:Programs:1 1: 1:program main -: 2: -: 3: implicit none -: 4: -: 5: integer :: a = 7 -: 6: 2: 7: if( a == 0 ) then #####: 8: print *, "a is null" -: 9: else if( a > 0 ) then 1: 10: print *, "a is positif" -: 11: else #####: 12: print *, "a is negatif" -: 13: end if -: 14: 2: 15:end program Note that line 7 is counted twice, as well as the last line ! -- Summary: [fortran] 'else if' statement is discarded and incoherent line count Product: gcc Version: 4.3.4 Status: UNCONFIRMED Severity: normal Priority: P3 Component: gcov-profile AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: Edouard dot Canot at irisa dot fr GCC build triplet: i686-linux-gnu GCC host triplet: i686-linux-gnu GCC target triplet: i686-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41359