From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 97BBA385E002; Tue, 24 Mar 2020 21:59:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 97BBA385E002 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1585087191; bh=Eu7FaLMrOCrfIe4WWMlAlxHWsCyBoVaxILXBStevN+U=; h=From:To:Subject:Date:From; b=jV58cw5tMYnpjupDp4SzMvx1xwFPb1m6/30slgGq1giY6oil6AliSgxVU3/QArzui 6dXdxsps/ISGQ8d7cd6nt0Ac+gn4c6io2cwWEVBP98RsejGVNZ0TG1l1jLzkOEUqfm BOb8fSCM07GbE58nthbjXLgyB3veJVWHuyDX/KuI= From: "glisse at gcc dot 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 10.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: glisse at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status keywords bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Mar 2020 21:59:51 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94314 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 k= now 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 coul= d do the same with the global replacable ones as well): #include int count =3D 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 co= unt. 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 someho= w...=