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++/108158] [11/12/13 Regression] modification of '...' is not a constant expression since r12-2304 Date: Fri, 03 Feb 2023 18:58:06 +0000 [thread overview] Message-ID: <bug-108158-4-F4lKdxZ4KC@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-108158-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108158 --- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The trunk branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>: https://gcc.gnu.org/g:27ac6a707e7438c3cec79c24f5d53de79493e2f8 commit r13-5693-g27ac6a707e7438c3cec79c24f5d53de79493e2f8 Author: Marek Polacek <polacek@redhat.com> Date: Mon Jan 30 09:02:00 2023 -0500 c++: wrong error with constexpr array and value-init [PR108158] In this test case, we find ourselves evaluating 't' which is ((const struct carray *) this)->data_[VIEW_CONVERT_EXPR<long int>(index)] in cxx_eval_array_reference. ctx->object is non-null, a RESULT_DECL, so we replace it with 't': new_ctx.object = t; // result_decl replaced and then we go to cxx_eval_constant_expression to evaluate an AGGR_INIT_EXPR, where we end up evaluating an INIT_EXPR (which is in the body of the constructor for seed_or_index): ((struct seed_or_index *) this)->value_ = NON_LVALUE_EXPR <0> whereupon in cxx_eval_store_expression we go to the probe loop where the 'this' is evaluated to ze_set.tables_.first_table_.data_[0] so the 'object' is ze_set, but that isn't in ctx->global->get_value_ptr so we fail with a bogus error. ze_set is not there because it comes from a different constexpr context (it's not in cv_cache either). The problem started with r12-2304 where I added the new_ctx.object replacement. That was to prevent a type mismatch: the type of 't' and ctx.object were different. It seems clear that we shouldn't have replaced ctx.object here. The cxx_eval_array_reference I mentioned earlier is called from cxx_eval_store_expression: 6257 init = cxx_eval_constant_expression (&new_ctx, init, vc_prvalue, 6258 non_constant_p, overflow_p); which already created a new context, whose .object we should be using unless, for instance, INIT contained a.b and we're evaluating the 'a' part, which I think was the case for r12-2304; in that case ctx.object has to be something different. It no longer seems necessary to replace new_ctx.object (likely due to changes in empty class handling). PR c++/108158 gcc/cp/ChangeLog: * constexpr.cc (cxx_eval_array_reference): Don't replace new_ctx.object. gcc/testsuite/ChangeLog: * g++.dg/cpp1y/constexpr-108158.C: New test.
next prev parent reply other threads:[~2023-02-03 18:58 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-12-17 21:00 [Bug c++/108158] New: modification of '...' is not a constant expression serge.guelton@telecom-bretagne.eu 2022-12-17 21:35 ` [Bug c++/108158] " pinskia at gcc dot gnu.org 2022-12-17 21:36 ` [Bug c++/108158] [11/12/13 Regression] " pinskia at gcc dot gnu.org 2022-12-20 16:58 ` [Bug c++/108158] [11/12/13 Regression] modification of '...' is not a constant expression since r12-2304 jakub at gcc dot gnu.org 2022-12-20 17:12 ` mpolacek at gcc dot gnu.org 2022-12-20 17:13 ` mpolacek at gcc dot gnu.org 2022-12-27 15:02 ` marxin at gcc dot gnu.org 2023-01-27 23:17 ` mpolacek at gcc dot gnu.org 2023-02-03 18:58 ` cvs-commit at gcc dot gnu.org [this message] 2023-02-03 18:59 ` [Bug c++/108158] [11/12 " mpolacek at gcc dot gnu.org 2023-05-29 10:07 ` jakub 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-108158-4-F4lKdxZ4KC@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).