[Bug gcov-profile/64634] New: gcov reports catch(...) as not executed

joerg.richter@pdv-fs.de gcc-bugzilla@gcc.gnu.org
Fri Jan 16 18:21:00 GMT 2015


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64634

            Bug ID: 64634
           Summary: gcov reports catch(...) as not executed
           Product: gcc
           Version: 4.8.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: gcov-profile
          Assignee: unassigned at gcc dot gnu.org
          Reporter: joerg.richter@pdv-fs.de

cat > t.cc <<EOF
#include <cstdlib>
void catchEx()
{
  exit(0);
  try
  {}
  catch( int )
  {}
}

int main()
{
  try
  {
    throw 5;
  }
  catch(...)
  {
    catchEx();
  }
}
EOF

g++ -o t t.cc -O0 --coverage -g
./t

-----

If you now call gcov like this:
gcov -b t.gcda

t.cc.gcov looks like this:

...
    =====:   18:  catch(...)
call    0 never executed
call    1 never executed
call    2 returned 100%
call    3 never executed
...

But if you call gcov like this:
gcov -a -b t.gcda
Then t.cc.gcov looks like this:

...
        1:   18:  catch(...)
    %%%%%:   18-block  0
call    0 never executed
call    1 never executed
    1:   18-block  1
    1:   18-block  2
call    2 returned 100%
    %%%%%:   18-block  3
call    3 never executed
...

Note that in the former case the catch(...) on line 18 is 
marked as not executed and in the later it is marked as 
executed. This results in wrong coverage information.

Calling gcov always with -a is no option for us. Because
gcov -a is much slower.

Works with GCC 4.4.4.  Fails since 4.5.



More information about the Gcc-bugs mailing list