From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id AD324385E004; Tue, 24 Mar 2020 20:44:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AD324385E004 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1585082695; bh=t3ppbpVvzAfBbVyIg90bH7LZEI4ZZMlUc39meP2qnPU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=UgekcsaIDl0dY1q4UqqUhpB5UZxl+qG8OjHIals/OeDoWOgVulfiLP7cyLtPjPef+ Fgt1JQOrRCGAGemhLLLAlIur3Kk/lx1ANgeoyhOgXFK6vlZ0XSaB8h3aVg6QSmbbfz 5jiff/Co84EWOZGpzaJkYNHasKAmFTEl7HrU7F3U= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/94295] use __builtin_operator_new and __builtin_operator_delete when available Date: Tue, 24 Mar 2020 20:44:55 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia 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: Message-ID: In-Reply-To: References: 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 20:44:55 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94295 --- Comment #3 from Andrew Pinski --- (In reply to Richard Smith from comment #2) > (In reply to Marc Glisse from comment #1) > > (In reply to Richard Smith from comment #0) > > > The C++ language rules do not permit optimization (eg, deletion) of d= irect > > > calls to 'operator new' and 'operator delete'. > >=20 > > I thought that was considered a bug? >=20 > No, it's intentional: if the user directly calls '::operator new(42)' and > they've replaced that function, the replacement function is guaranteed to= be > called. In this regard, 'operator new' is just a regular function with a > funny name. >=20 > To be clear, the implicit call to 'operator new' produced by, say, 'new i= nt' > *is* optimizable, but a direct explicit call to 'operator new(sizeof(int)= )' > is not. >=20 > > Gcc does optimize those, like it does malloc/free... >=20 > That sounds like non-conforming behavior. PR 23383 is where part of the discussion was done. In fact GCC implements the optimization without the builtin: https://gcc.gnu.org/legacy-ml/gcc-patches/2019-07/msg00136.html=