https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98631
Martin Liška <marxin at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW CC| |jakub at gcc dot gnu.org Ever confirmed|0 |1 Last reconfirmed| |2021-01-12 --- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> --- Thank you Marek for the report, I can confirm it. What happens: $ g++ pr98631.C --coverage -fdump-ipa-profile-details-lineno ... int main () { struct S s; int D.2411; void * _1; int _11; <bb 2> : [pr98631.C:14:7] S::S ([pr98631.C:14:7] &s); <bb 3> : s ={v} {CLOBBER}; <bb 4> : [pr98631.C:19:1] _11 = 0; <bb 5> : <L1>: [pr98631.C:19:1] return _11; <bb 6> : <L2>: s ={v} {CLOBBER}; resx 2 <bb 7> : <L3>: [pr98631.C:16:3] eh_dispatch 1 <bb 8> : <L4>: [pr98631.C:16:9] _1 = __builtin_eh_pointer (1); [pr98631.C:16:9] __cxa_begin_catch (_1); <bb 9> : [pr98631.C:17:22] __builtin_puts (&"caught"[0]); <bb 10> : [pr98631.C:16:9] __cxa_end_catch (); goto <bb 4>; [INV] <bb 11> : <L5>: [pr98631.C:16:9] __cxa_end_catch (); <bb 12> : resx 4 } -: 15: } 2: 16: catch(...) { 1: 17: __builtin_printf ("caught\n"); -: 18: } In my case line 16 is present in BB 7, 8, 10 and 11. $ gcov a-pr98631.C -t --debug source_info: pr98631.C function_info: main block_info id=0, count=1 block_info id=1, count=1 block_info id=2, count=1 block_info id=3, count=0 block_info id=4, count=1 block_info id=5, count=1 block_info id=6, count=1 block_info id=7, count=1 block_info id=8, count=1 block_info id=9, count=1 block_info id=10, count=1 block_info id=11, count=0 block_info id=12, count=0 as seen, bb_9 is executed and that's the place where we "leave" line 16, enter line 17 and then again enter 16 in bb_10. That's why we see the line being executed twise. It's not easy to fix :/ Btw. started with r5-7298-g3b445b24ddadf8a9.