From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 224383858C2C; Mon, 25 Oct 2021 01:10:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 224383858C2C From: "xmh970252187 at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/102514] The allocation function shall not be called when existing an erroneous expression in noptr-new-declarator Date: Mon, 25 Oct 2021 01:10:22 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: xmh970252187 at gmail dot com 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: Mon, 25 Oct 2021 01:10:23 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102514 --- Comment #2 from jim x --- It seems that they all do not obey [expr.new] p9, which says that If the expression in a noptr-new-declarator is present, it is implicitly converted to std=E2=80=8B::=E2=80=8Bsize_=C2=ADt. The expression is erroneo= us if: - the expression is of non-class type and its value before converting to std=E2=80=8B::=E2=80=8Bsize_=C2=ADt is less than zero; - [...] If the expression is erroneous after converting to std=E2=80=8B::=E2=80=8Bs= ize_=C2=ADt:=20 - if the expression is a core constant expression, the program is ill-forme= d;=20 - otherwise, an allocation function is not called; instead - if the allocation function that would have been called has a non-throwi= ng=20 exception specification ([except.spec]), the value of the new-expressio= n is=20 the null pointer value of the required result type;=20=20 - otherwise, the new-expression terminates by throwing an exception of a = type=20 that would match a handler ([except.handle]) of type std=E2=80=8B::=E2=80=8Bbad_=C2=ADarray_=C2=ADnew_=C2=AD=20 length.=