public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/106965] g++ optimization removes assigning 0 to deleted pointer- causes double free.
Date: Tue, 20 Sep 2022 09:00:45 +0000 [thread overview]
Message-ID: <bug-106965-4-6AqLcAFnZS@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-106965-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106965
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #1)
> I think it's undefined to invoke a DTOR twice which is what you do here.
> After the DTOR the m_ptr member becomes undefined so re-evaluating that in
> the second invocation (when there's no object of type X anymore) is
> undefined.
Right, and because you can't ever use the m_ptr member after the destructor,
there's no point writing the 0 to it. That's a dead store, so the compiler is
allowed to eliminate it. A correct program can never observe whether that store
happened or not.
next prev parent reply other threads:[~2022-09-20 9:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-19 10:21 [Bug c++/106965] New: " olddra3rd at mozmail dot com
2022-09-19 11:29 ` [Bug c++/106965] " rguenth at gcc dot gnu.org
2022-09-19 13:06 ` olddra3rd at mozmail dot com
2022-09-20 9:00 ` redi at gcc dot gnu.org [this message]
2022-09-20 10:02 ` olddra3rd at mozmail dot com
2022-09-20 10:18 ` redi at gcc dot gnu.org
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bug-106965-4-6AqLcAFnZS@http.gcc.gnu.org/bugzilla/ \
--to=gcc-bugzilla@gcc.gnu.org \
--cc=gcc-bugs@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).