From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30270 invoked by alias); 22 Feb 2012 12:56:23 -0000 Received: (qmail 30258 invoked by uid 22791); 22 Feb 2012 12:56:22 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 22 Feb 2012 12:55:35 +0000 From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/52339] using delete ptr1->ptr2 where ptr2 destructor deletes a const ptr1 fails Date: Wed, 22 Feb 2012 13:07:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: major X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-02/txt/msg02197.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52339 --- Comment #2 from Jonathan Wakely 2012-02-22 12:48:04 UTC --- b = b.0; a = b->a; D.2361 = a->b; if (D.2361 != 0B) goto ; else goto ; : 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 ; else goto ; : B::~B (D.2361); operator delete (D.2361); calling the destructor and operator delete directly on the value of a->b