Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#154 lcov failed to anaylze "return" statement after goto label

Miscellaneous
open
nobody
Tools (21)
5
2010-06-22
2010-06-22
Anonymous
No

code like,
-------------------------

1 : :
2 : : #include <stdio.h>
3 : :
4 : :
5 : 1 : int main()
6 : : {
7 : 1 : int n = 199;
8 : 1 : int i = 0;
9 : :
10 [ + + ]: 200 : for (i = 0; i < n; i++) {
11 : 199 : printf("gcov goto testing %d/199\n", i + 1);
12 : :
13 [ - + ]: 199 : if (i < 0) {
14 : 0 : goto fail;
15 : : }
16 : : }
17 : :
18 : 1 : return 0;
19 : :
20 : : fail:
21 : 1 : return -1;
22 : :
23 : : }
24 : :
--------------------------

on line 21, lcov definitely did wrong.

Discussion

  • This looks like it may result from using GCC optimization together with code coverage measurement. Since lcov builds on the output of GCC's gcov, the same restrictions apply. Please see section "Using gcov with GCC Optimization" in the gcov man for an explanation of why the above may happen and how to prevent it.