https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88742
Bug ID: 88742 Summary: Debugger jumps back when stepping over class destructor Product: gcc Version: 8.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: debug Assignee: unassigned at gcc dot gnu.org Reporter: ks1322 at gmail dot com Target Milestone: --- This is basically the same bug report as the Bug 49951 because it can be reproduced with recent version of gcc. I don't know whether Bug 49951 should be reopened or not, so I am reporting the new one. In short, when stepping to destructor code in debugger, it jumps back to the declaration of the class. The code: #include <stdio.h> class MyClass { public: MyClass() {}; // constructor ~MyClass() {}; // destructor }; int main () { int i = 1; MyClass m; if (i == 1) { printf ("Hello world %d\n", i); } } Compiling: g++ -Wall -Wextra -g -O0 t03.cpp Debugging: $ gdb -q a.out Reading symbols from a.out...done. (gdb) start Temporary breakpoint 1 at 0x40114f: file t03.cpp, line 13. Starting program: /tmp/a.out Missing separate debuginfos, use: dnf debuginfo-install glibc-2.28-23.fc29.x86_64 Temporary breakpoint 1, main () at t03.cpp:13 13 int i = 1; Missing separate debuginfos, use: dnf debuginfo-install libgcc-8.2.1-5.fc29.x86_64 libstdc++-8.2.1-5.fc29.x86_64 (gdb) n 14 MyClass m; (gdb) 16 if (i == 1) (gdb) 18 printf ("Hello world %d\n", i); (gdb) Hello world 1 14 MyClass m; (gdb) 20 } Note the jump back to line 14 before continuing to line 20. I don't observe this behavior with clang, no jumps back in debugger (clang version 7.0.0).