public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/102359] ICE gimplification failed since r12-3433-ga25e0b5e6ac8a77a
Date: Thu, 16 Sep 2021 09:37:14 +0000	[thread overview]
Message-ID: <bug-102359-4-bsDDVhabVQ@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-102359-4@http.gcc.gnu.org/bugzilla/>

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.  So we end with '&__closure->__this' which indeed isn't an lvalue.

The issue here is that we are initializing the VAR_DECL 'this' but that
has a DECL_VALUE_EXPR expanding to &__closure->__this:

const struct A * const this [value-expr: &__closure->__this];

note the variable is const as well, so emitting a runtime initializer might
have other issues (like trapping ...), or in this case, not being an lvalue.

But note the FE fails to mark the decl as TREE_READONLY - that would be an
easy thing to check (and something we fail to check in is_var_need_auto_init).
Thus sth like

diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index f680292fd91..b2bfab47a2f 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -1824,7 +1824,9 @@ gimple_add_padding_init_for_auto_var (tree decl, bool
is_vla,
 static bool
 is_var_need_auto_init (tree decl)
 {
-  if (auto_var_p (decl)
+  if (VAR_P (decl)
+      && !TREE_READONLY (decl)
+      && auto_var_p (decl)
       && (flag_auto_var_init > AUTO_INIT_UNINITIALIZED)
       && (!lookup_attribute ("uninitialized", DECL_ATTRIBUTES (decl)))
       && !is_empty_type (TREE_TYPE (decl)))

should be needed.

Jason, any idea?

  parent reply	other threads:[~2021-09-16  9:37 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-16  8:54 [Bug tree-optimization/102359] New: " marxin at gcc dot gnu.org
2021-09-16  8:54 ` [Bug tree-optimization/102359] " marxin at gcc dot gnu.org
2021-09-16  9:37 ` rguenth at gcc dot gnu.org [this message]
2021-09-29 16:28 ` qinzhao at gcc dot gnu.org
2021-10-05 23:14 ` cvs-commit at gcc dot gnu.org
2021-10-05 23:16 ` qinzhao 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-102359-4-bsDDVhabVQ@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).