https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110561
Ivan Sorokin <vanyacpp at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |vanyacpp at gmail dot com --- Comment #1 from Ivan Sorokin <vanyacpp at gmail dot com> --- Smaller reproducer: struct non_trivial { non_trivial(); non_trivial(non_trivial const&); non_trivial& operator=(non_trivial const&); ~non_trivial(); void escape(); }; non_trivial foobar() { non_trivial result; result.escape(); return result; } https://gcc.godbolt.org/z/s5fG6ezxd Here is the code generated after escape() until the end of function: .LEHB1: call non_trivial::escape() .LEHE1: .loc 1 15 12 nop mov rax, QWORD PTR __gcov0.foobar()[rip+24] add rax, 1 mov QWORD PTR __gcov0.foobar()[rip+24], rax jmp .L5 # unconditional jump to function exit .L4: mov rbx, rax # exceptional case mov rax, QWORD PTR __gcov0.foobar()[rip+16] add rax, 1 mov QWORD PTR __gcov0.foobar()[rip+16], rax .loc 1 16 1 mov rax, QWORD PTR [rbp-24] mov rdi, rax call non_trivial::~non_trivial() [complete object destructor] mov rax, QWORD PTR __gcov0.foobar()[rip+32] # increments the counter for } add rax, 1 mov QWORD PTR __gcov0.foobar()[rip+32], rax mov rax, rbx mov rdi, rax .LEHB2: call _Unwind_Resume .LEHE2: .L5: mov rax, QWORD PTR [rbp-24] # doesn't increment the counter for } mov rbx, QWORD PTR [rbp-8] leave .cfi_def_cfa 7, 8 ret .cfi_endproc >From what I understand the counter for } is incremented in the exceptional codepath that is executed when an exception is thrown from escape(). Normal codepath doesn't increment it. This looks like a bug to me. The counter for } should be either incremented on both codepaths or should not exist at all.