http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52339
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-02-22
12:48:04 UTC ---
b = b.0;
a = b->a;
D.2361 = a->b;
if (D.2361 != 0B) goto <D.2362>; else goto <D.2363>;
<D.2362>:
D.2364 = a->b;
B::~B (D.2364);
D.2365 = a->b;
operator delete (D.2365);
which is indeed as if written like:
a->b->~B();
operator delete(a->b); // a is already deleted
if 'a' is not a pointer-to-const then instead you get
b = b.0;
a = b->a;
D.2361 = a->b;
if (D.2361 != 0B) goto <D.2362>; else goto <D.2363>;
<D.2362>:
B::~B (D.2361);
operator delete (D.2361);
calling the destructor and operator delete directly on the value of a->b