views:

119

answers:

1

If I dump the code generated by GCC for a virtual destructor (with -fdump-tree-original), I get something like this:

;; Function virtual Foo::~Foo() (null)
;; enabled by -tree-original

{
  <<cleanup_point <<< Unknown tree: expr_stmt
  (void) (((struct Foo *) this)->_vptr.Foo = &_ZTV3Foo + 8) >>>
>>;
}
<D.20148>:;
if ((bool) (__in_chrg & 1))
  {
    <<cleanup_point <<< Unknown tree: expr_stmt
  operator delete ((void *) this) >>>
>>;
  }

My question is: where is the code after "<D.20148>:;" located? It is outside of the destructor so when is this code executed?

A: 

That looks like the compiler-generated code to manage the actual memory deallocation after the destructor is called and should execute right after your destructor code.

Mark B
After looking at the assembly output, it looks like you're right. But do you have any idea why the code is shown outside of the destructor and what the label means?
Job
The compiler is showing you what it generated corresponding to code you wrote. The code after that label is auto-generated and is actually induced by the delete call, not your destructor. Even though it's called right after the destructor it's not part of the destructor code. I don't have any idea what the label means though.
Mark B