public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "glisse at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/94314] New: [10 Regression] Optimizing mismatched new/delete pairs Date: Tue, 24 Mar 2020 21:59:51 +0000 [thread overview] Message-ID: <bug-94314-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94314 Bug ID: 94314 Summary: [10 Regression] Optimizing mismatched new/delete pairs Product: gcc Version: 10.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: glisse at gcc dot gnu.org Target Milestone: --- (originally posted at https://gcc.gnu.org/legacy-ml/gcc-patches/2019-08/msg00276.html , I don't know if we will do something about it, but it seems worth documenting it in bugzilla) Now that we optimize class-specific operator new/delete pairs (but you could do the same with the global replacable ones as well): #include <stdio.h> int count = 0; struct A { __attribute__((malloc,noinline)) static void* operator new(unsigned long sz){++count;return ::operator new(sz);} static void operator delete(void* ptr){--count;::operator delete(ptr);} }; int main(){ delete new A; printf("%d\n",count); // Should print 0. } If we do not inline anything, we can remove the pair and nothing touches count. If we inline both new and delete, we can then remove the inner pair instead, count increases and decreases, fine. If we inline only one of them, and DCE the mismatched pair new/delete, we get something inconsistent (count is -1). This seems to indicate we should check that the new and delete match somehow...
next reply other threads:[~2020-03-24 21:59 UTC|newest] Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-03-24 21:59 glisse at gcc dot gnu.org [this message] 2020-03-24 22:29 ` [Bug c++/94314] " jason at gcc dot gnu.org 2020-03-25 7:55 ` rguenth at gcc dot gnu.org 2020-03-25 10:08 ` [Bug c++/94314] [10 Regression] Optimizing mismatched new/delete pairs since r10-2106-g6343b6bf3bb83c87 marxin at gcc dot gnu.org 2020-03-25 10:44 ` rguenth at gcc dot gnu.org 2020-03-25 11:24 ` glisse at gcc dot gnu.org 2020-03-27 21:43 ` jason at gcc dot gnu.org 2020-03-30 7:57 ` marxin at gcc dot gnu.org 2020-04-01 7:48 ` rguenth at gcc dot gnu.org 2020-04-08 15:17 ` cvs-commit at gcc dot gnu.org 2020-04-08 15:18 ` marxin at gcc dot gnu.org 2020-04-08 16:02 ` glisse at gcc dot gnu.org 2020-04-08 18:04 ` cvs-commit at gcc dot gnu.org 2020-04-09 13:55 ` marxin at gcc dot gnu.org 2020-04-16 13:40 ` cvs-commit at gcc dot gnu.org 2020-04-16 13:41 ` marxin at gcc dot gnu.org 2020-04-17 7:02 ` cvs-commit 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-94314-4@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: linkBe 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).