public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/99934] bad_array_new_length thrown when non-throwing allocation function would have been used Date: Tue, 06 Apr 2021 12:41:34 +0000 [thread overview] Message-ID: <bug-99934-4-2ALdgvChHh@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-99934-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99934 --- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> --- For the non-global replaceable operator new call, we put the outer_nelts_check already into the size argument before we actually look up the call: tree errval = TYPE_MAX_VALUE (sizetype); if (cxx_dialect >= cxx11 && flag_exceptions) errval = throw_bad_array_new_length (); if (outer_nelts_check != NULL_TREE) size = fold_build3 (COND_EXPR, sizetype, outer_nelts_check, size, errval); ... alloc_call = build_new_method_call (dummy, fns, &align_args, /*conversion_path=*/NULL_TREE, LOOKUP_NORMAL, &alloc_fn, tf_none); ... alloc_call = build_new_method_call (dummy, fns, placement, /*conversion_path=*/NULL_TREE, LOOKUP_NORMAL, &alloc_fn, complain); So I guess either we should after alloc_call is built look whether it is noexcept/throw() and if so, wrap it into another COND_EXPR with unshare_expr of outer_nelts_check and alloc_call, build_zero_cst (TREE_TYPE (alloc_call)), or perhaps that + at that point try to simplify the size argument of the call. But I think any kind of CSE in GIMPLE or RTL optimizations should optimize that already and so the FE doesn't need to duplicate such optimization. Plus verify what happens with the global replaceable operators. And another thing is constant expression evaluation, http://eel.is/c++draft/expr.new#9.5 says we should reject it during constant expression evaluation, but if we represent it as COND_EXPR something, operator new (...), nullptr then I'm afraid constant expression evaluation would accept it and evaluate to nullptr.
next prev parent reply other threads:[~2021-04-06 12:41 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-04-06 11:33 [Bug c++/99934] New: " redi at gcc dot gnu.org 2021-04-06 12:41 ` jakub at gcc dot gnu.org [this message] 2022-03-28 9:17 ` [Bug c++/99934] " redi at gcc dot gnu.org 2023-03-20 9:52 ` redi at gcc dot gnu.org 2023-03-20 10:08 ` redi at gcc dot gnu.org 2023-03-20 10:23 ` redi at gcc dot gnu.org 2024-04-22 16:14 ` redi 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-99934-4-2ALdgvChHh@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).