From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id AB2DC3858D38; Sun, 15 Jan 2023 22:53:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AB2DC3858D38 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1673823197; bh=pNGHVEzudJztptWtqxabFgRGdgZpLMuu7dOq8i7QcEc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=QGDwlsaabwJ6W4fGeQhpen3aWeP03Fi8DMi2fV/CkT+/d3zChQ8REMPUkItTEL0ht sH+mY8fx5jbKcR1C0rIqeDXq80O+vNEhSNQListCm+I4KLeEgR8B3FnGGhwkGP2+5G TWD2UL99vgIO9SoRN50oJkgb+Nyz+tO3L6eAIwes= From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/106477] With -fno-exception operator new(nothrow) aborts instead of returning null Date: Sun, 15 Jan 2023 22:53:17 +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: 11.2.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: NEW 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106477 --- Comment #7 from Jonathan Wakely --- (In reply to Matthijs Kooijman from comment #6) > Ah, IIUC your patch does not treat -fno-exceptions specially, but just ad= ds > a shortcut for the nothrow new version to skip calling regular new version > if it has not been replaced. In a normal build, that saves throw/catch > overhead, and in a no-exceptions build that prevents the abort associated > with that throw. Clever! Right. > One corner case seems to be when the regular new version is replaced in a > no-exceptions build, but in that case that replacement has no way to sign= al > failure anyway, and if needed a user can just also replace the nothrow > version. If the regular version has been replaced, we have to call it (and handle possible exceptions) because we can't know what it does, so calling malloc directly would not be safe. So yes, users who want to replace new but don't want exceptions involved in the nothrow new path just need to replace both forms. That's true already today, and my patch wouldn't change it.=