This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/52339] using delete ptr1->ptr2 where ptr2 destructor deletes a const ptr1 fails


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]