https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82527
Martin Liška <marxin at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |RESOLVED Resolution|--- |INVALID --- Comment #2 from Martin Liška <marxin at gcc dot gnu.org> --- Thanks for the issue. Note that order of branches which go from switch statement to corresponding case labels is not ordered. With new GCC 8.1, we'll come up with '-w' option. Then you'll see the connections (edges): $ rm *.gcda && gcc pr82527.c --coverage && ./a.out && gcov -abw pr82527.c && cat pr82527.c.gcov 0dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddFile 'pr82527.c' Lines executed:83.33% of 12 Branches executed:100.00% of 5 Taken at least once:80.00% of 5 No calls Creating 'pr82527.c.gcov' -: 0:Source:pr82527.c -: 0:Graph:pr82527.gcno -: 0:Data:pr82527.gcda -: 0:Runs:1 -: 0:Programs:1 -: 1:#include <stdio.h> -: 2:int function main called 1 returned 100% blocks executed 91% 1: 3:main () -: 4:{ 101: 5: for (int i = 0; i < 100; i++) 1: 5-block 0 (BB 2) 100: 5-block 1 (BB 9) 101: 5-block 2 (BB 10) branch 0 taken 99% (BB 3) branch 1 taken 1% (fallthrough) (BB 11) -: 6: { 100: 7: switch (i) 100: 7-block 0 (BB 3) branch 0 taken 1% (BB 4) branch 1 taken 0% (BB 6) branch 2 taken 99% (BB 7) -: 8: { 1: 9: case 0: 1: 10: printf ("0"); 1: 10-block 0 (BB 4) call 0 returned 100% 1: 11: break; #####: 12: case 9999: #####: 13: break; $$$$$: 13-block 0 (BB 6) 99: 14: default: 99: 15: printf ("d"); 99: 15-block 0 (BB 7) call 0 returned 100% 99: 16: break; -: 17: } -: 18: } 1: 19: return 0; 1: 19-block 0 (BB 11) -: 20:} $ rm *.gcda && gcc -O3 pr82527.c --coverage && ./a.out && gcov -abw pr82527.c && cat pr82527.c.gcov 0dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddFile 'pr82527.c' Lines executed:100.00% of 9 Branches executed:100.00% of 4 Taken at least once:75.00% of 4 No calls Creating 'pr82527.c.gcov' -: 0:Source:pr82527.c -: 0:Graph:pr82527.gcno -: 0:Data:pr82527.gcda -: 0:Runs:1 -: 0:Programs:1 -: 1:#include <stdio.h> -: 2:int function main called 1 returned 100% blocks executed 100% 1: 3:main () -: 4:{ 101: 5: for (int i = 0; i < 100; i++) 1: 5-block 0 (BB 2) 100: 5-block 1 (BB 8) 101: 5-block 2 (BB 9) branch 0 taken 99% (BB 3) branch 1 taken 1% (fallthrough) (BB 10) -: 6: { 100: 7: switch (i) 100: 7-block 0 (BB 3) branch 0 taken 1% (BB 4) branch 1 taken 99% (BB 6) branch 2 taken 0% (BB 8) -: 8: { 1: 9: case 0: 1: 10: printf ("0"); 1: 10-block 0 (BB 4) call 0 returned 100% 1: 11: break; -: 12: case 9999: -: 13: break; 99: 14: default: 99: 15: printf ("d"); 99: 15-block 0 (BB 6) call 0 returned 100% 99: 16: break; -: 17: } -: 18: } -: 19: return 0; -: 20:} And you're right w/ -O3 it goes to a different BB and order is changed. Hope it will help you? I'm closing it as invalid.