public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "mpolacek at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/107079] [10/11/12/13 Regression] ICE initializing lifetime-extended constexpr variable that stores its this pointer Date: Fri, 03 Feb 2023 20:59:45 +0000 [thread overview] Message-ID: <bug-107079-4-PygkkxjSMR@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-107079-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107079 --- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> --- Very interesting. We're in store_init_value, initializing x with &TARGET_EXPR <D.2768, {.x=(const struct X *) &<PLACEHOLDER_EXPR struct X>}> but we must lifetime-extend via extend_ref_init_temps and we get _ZGR1x_.x = (const struct X *) &<PLACEHOLDER_EXPR struct X> >>>;, (const struct X &) &_ZGR1x_; Since x was declared constexpr, we do cxx_constant_init (not quiet) and we hit the code added in r269003: + bool preeval = SCALAR_TYPE_P (type) || TREE_CODE (t) == MODIFY_EXPR; + if (preeval) + { + /* Evaluate the value to be stored without knowing what object it will be + stored in, so that any side-effects happen first. */ + if (!SCALAR_TYPE_P (type)) + new_ctx.ctor = new_ctx.object = NULL_TREE; + init = cxx_eval_constant_expression (&new_ctx, init, false, + non_constant_p, overflow_p); while evaluating the INIT_EXPR _ZGR1x_.x = (const struct X *) &<PLACEHOLDER_EXPR struct X> >>>. But we have no ctx.ctor or ctx.object here so lookup_placeholder won't find anything and we ICE on 7861 /* A placeholder without a referent. We can get here when 7862 checking whether NSDMIs are noexcept, or in massage_init_elt; 7863 just say it's non-constant for now. */ 7864 gcc_assert (ctx->quiet); Somehow we should manage that the PLACEHOLDER_EXPR is replaced with _ZGR1x_ I guess.
next prev parent reply other threads:[~2023-02-03 20:59 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-09-28 21:58 [Bug c++/107079] New: " johelegp at gmail dot com 2022-09-29 14:26 ` [Bug c++/107079] [10/11/12/13 Regression] " mpolacek at gcc dot gnu.org 2023-02-03 20:59 ` mpolacek at gcc dot gnu.org [this message] 2023-02-03 23:32 ` mpolacek at gcc dot gnu.org 2023-02-07 21:01 ` mpolacek at gcc dot gnu.org 2023-02-08 19:01 ` mpolacek at gcc dot gnu.org 2023-02-10 0:06 ` cvs-commit at gcc dot gnu.org 2023-02-10 0:07 ` [Bug c++/107079] [10/11/12 " mpolacek at gcc dot gnu.org 2023-03-07 16:24 ` cvs-commit at gcc dot gnu.org 2023-03-07 16:25 ` [Bug c++/107079] [10/11 " mpolacek at gcc dot gnu.org 2023-06-30 13:58 ` 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-107079-4-PygkkxjSMR@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).