public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "StevenSun2021 at hotmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/108218] [12/13 Regression] Constant arguments in the new expression is not checked in unevaluated operand Date: Sat, 24 Dec 2022 22:53:09 +0000 [thread overview] Message-ID: <bug-108218-4-G1PFS7nTKS@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-108218-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108218 --- Comment #7 from Steven Sun <StevenSun2021 at hotmail dot com> --- I got one simple idea as a workaround. I do not have the resources to do the tests. I agree anyone to take the following patch or the idea. From 35b4186a0ed3671de603bed6df5fb1156f087581 Mon Sep 17 00:00:00 2001 From: Steven Sun <stevensun2021@hotmail.com> Date: Sun, 25 Dec 2022 06:44:43 +0800 Subject: [PATCH] c++: escape unevaluated context in new-expression --- gcc/cp/init.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gcc/cp/init.cc b/gcc/cp/init.cc index b49a7ca9169..974ea95959e 100644 --- a/gcc/cp/init.cc +++ b/gcc/cp/init.cc @@ -3929,7 +3929,12 @@ build_new (location_t loc, vec<tree, va_gc> **placement, tree type, /* Try to determine the constant value only for the purposes of the diagnostic below but continue to use the original value and handle const folding later. */ + /* Escape the possible unevaluated context. Constant folding does + not work in unevaluated context, but is required in nelts. */ + int old_cp_unevaluated_operand = cp_unevaluated_operand; + cp_unevaluated_operand = false; const_tree cst_nelts = fold_non_dependent_expr (nelts, complain); + cp_unevaluated_operand = old_cp_unevaluated_operand; /* The expression in a noptr-new-declarator is erroneous if it's of non-class type and its value before converting to std::size_t is -- 2.34.1
next prev parent reply other threads:[~2022-12-24 22:53 UTC|newest] Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-12-24 15:52 [Bug c++/108218] New: [12 " StevenSun2021 at hotmail dot com 2022-12-24 16:00 ` [Bug c++/108218] " StevenSun2021 at hotmail dot com 2022-12-24 19:19 ` [Bug c++/108218] [12/13 " pinskia at gcc dot gnu.org 2022-12-24 20:44 ` StevenSun2021 at hotmail dot com 2022-12-24 20:46 ` pinskia at gcc dot gnu.org 2022-12-24 20:49 ` StevenSun2021 at hotmail dot com 2022-12-24 20:56 ` StevenSun2021 at hotmail dot com 2022-12-24 22:53 ` StevenSun2021 at hotmail dot com [this message] 2022-12-27 12:24 ` [Bug c++/108218] [12/13 Regression] Constant arguments in the new expression is not checked in unevaluated operand since r12-5253-g4df7f8c79835d569 marxin at gcc dot gnu.org 2023-01-09 13:42 ` rguenth at gcc dot gnu.org 2023-01-10 15:16 ` ppalka at gcc dot gnu.org 2023-01-10 18:52 ` pinskia at gcc dot gnu.org 2023-01-21 17:22 ` StevenSun2021 at hotmail dot com 2023-01-25 2:59 ` jason at gcc dot gnu.org 2023-01-25 3:19 ` jason at gcc dot gnu.org 2023-03-01 19:09 ` cvs-commit at gcc dot gnu.org 2023-04-28 22:13 ` [Bug c++/108218] [12/13/14 " cvs-commit at gcc dot gnu.org 2023-05-08 12:26 ` rguenth at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-108218-4-G1PFS7nTKS@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).