From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 184DE3858D1E; Sat, 24 Dec 2022 15:52:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 184DE3858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1671897177; bh=caLBg0fWKeRiJ6jxMFPhvSdj6EoIEE2C8n44P689LRo=; h=From:To:Subject:Date:From; b=o80zZfd5HTCdL7lbmdFMnzVPx1k+H8W9bahGJyUFfGFQzqaXvX/klGBAuidW9nnUD DK9uAkKzrFo56X0q7EQIkx9wECRleYYCy6rMj+acfDO7eO9ANBwNLYyTafsH2yGKEd 2hE9YD0Q4PuCSVFPiOE+anT8QLbQK2k1y94f0WEQ= From: "StevenSun2021 at hotmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/108218] New: [12 Regression] Constant arguments in the new expression is not checked in unevaluated operand Date: Sat, 24 Dec 2022 15:52:56 +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: 12.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: StevenSun2021 at hotmail 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: bug_id short_desc product version bug_status 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D108218 Bug ID: 108218 Summary: [12 Regression] Constant arguments in the new expression is not checked in unevaluated operand Product: gcc Version: 12.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: StevenSun2021 at hotmail dot com Target Milestone: --- ``` int main() { decltype(new int[-1]) a; // compiles with g++-12! <- regression here // does not compile with g++-11 auto b =3D new int[-1]; // does not compile with g++-12 // does not compile with g++-11 } ``` https://godbolt.org/z/aMGMrbfrd expected behavior: if, after conversion to std::size_t, the first dimension is a core constant expression and it is potentially evaluated, the program is ill-formed. https://en.cppreference.com/w/cpp/language/new gcc(<=3D11.3 (current version)) and clang(>=3D3) does this check.=