0

I set a breakpoint in a destructor, which only gets called, when the program finishes completely. Now I start the program with CLion's debugger, but it never reaches the destructor. When I press on finish in CLion the debugger closes and the breakpoint never gets reached. How can I reach the breakpoint in the destructor in CLion?

Jan Deinhard
  • 19,645
  • 24
  • 81
  • 137
Hakaishin
  • 2,550
  • 3
  • 27
  • 45

1 Answers1

0

You need to find a way to stop looping in your main thread, and jump to return 0; at the end of your int main(...) {. Alternatively, you can use exit(0), I believe. (Source: Difference between "return 0" and "exit (0)")

There's more:

You need to share your code, but there's this information, which you may find useful:

Please see these references:

Are Basic Object Destructors Called On Exit()?

Note that objects with automatic storage are not destroyed by calling exit (C++). http://www.cplusplus.com/reference/cstdlib/exit/

The problem could be that, during exit, your destructor is never called, anyway. Hence, it is a leak but the OS will handle it.

Community
  • 1
  • 1
Okan Barut
  • 279
  • 1
  • 7