public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/108219] [12/13 Regression] requirement fails on a valid expression since r12-5253-g4df7f8c79835d569
Date: Wed, 01 Mar 2023 19:09:48 +0000	[thread overview]
Message-ID: <bug-108219-4-rSomBSbPjL@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-108219-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108219

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:

https://gcc.gnu.org/g:096f034a8f5df41f610e62c1592fb90a3f551cd5

commit r13-6395-g096f034a8f5df41f610e62c1592fb90a3f551cd5
Author: Patrick Palka <ppalka@redhat.com>
Date:   Wed Mar 1 14:09:37 2023 -0500

    c++: unevaluated array new-expr size constantness [PR108219]

    Here we're mishandling the unevaluated array new-expressions due to a
    supposed non-constant array size ever since r12-5253-g4df7f8c79835d569
    made us no longer perform constant evaluation of non-manifestly-constant
    expressions within unevaluated contexts.  This shouldn't make a difference
    here since the array sizes are constant literals, except they're expressed
    as NON_LVALUE_EXPR location wrappers around INTEGER_CST, wrappers which
    used to get stripped as part of constant evaluation and now no longer do.
    Moreover it means build_vec_init can't constant fold the MINUS_EXPR
    'maxindex' passed from build_new_1 when in an unevaluated context (since
    it tries reducing it via maybe_constant_value called with mce_unknown).

    This patch fixes these issues by making maybe_constant_value (and
    fold_non_dependent_expr) try folding an unevaluated non-manifestly-constant
    operand via fold(), as long as it simplifies to a simple constant, rather
    than doing no simplification at all.  This covers e.g. simple arithmetic
    and casts including stripping of location wrappers around INTEGER_CST.

    In passing, this patch also fixes maybe_constant_value to avoid constant
    evaluating an unevaluated operand when called with mce_false, by adjusting
    the early exit test appropriately.

    Co-authored-by: Jason Merrill <jason@redhat.com>

            PR c++/108219
            PR c++/108218

    gcc/cp/ChangeLog:

            * constexpr.cc (fold_to_constant): Define.
            (maybe_constant_value): Move up early exit test for unevaluated
            operands.  Try reducing an unevaluated operand to a constant via
            fold_to_constant.
            (fold_non_dependent_expr_template): Add early exit test for
            CONSTANT_CLASS_P nodes.  Try reducing an unevaluated operand
            to a constant via fold_to_constant.
            * cp-tree.h (fold_to_constant): Declare.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp0x/new6.C: New test.
            * g++.dg/cpp2a/concepts-new1.C: New test.

  parent reply	other threads:[~2023-03-01 19:09 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-24 22:04 [Bug c++/108219] New: requirement fails on a valid expression vanyacpp at gmail dot com
2022-12-24 23:33 ` [Bug c++/108219] [12/13 Regression] " pinskia at gcc dot gnu.org
2022-12-27 12:35 ` [Bug c++/108219] [12/13 Regression] requirement fails on a valid expression since r12-5253-g4df7f8c79835d569 marxin at gcc dot gnu.org
2023-01-09 13:42 ` rguenth at gcc dot gnu.org
2023-02-22 17:19 ` ppalka at gcc dot gnu.org
2023-03-01 19:09 ` cvs-commit at gcc dot gnu.org [this message]
2023-03-01 19:11 ` [Bug c++/108219] [12 " ppalka at gcc dot gnu.org
2023-03-03  9:35 ` vanyacpp at gmail dot com
2023-04-28 22:13 ` cvs-commit at gcc dot gnu.org
2023-04-28 22:16 ` ppalka 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-108219-4-rSomBSbPjL@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: link
Be 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).