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 fortran/113503] [14 Regression] xtb test miscompilation starting with r14-870
Date: Fri, 16 Feb 2024 12:47:02 +0000	[thread overview]
Message-ID: <bug-113503-4-Tkh8T3lvoG@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-113503-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
For the warning case, I think
--- gcc/fortran/trans-expr.cc.jj        2024-02-14 14:26:19.764810614 +0100
+++ gcc/fortran/trans-expr.cc   2024-02-16 13:22:48.693104239 +0100
@@ -9253,19 +9253,20 @@ gfc_trans_subcomponent_assign (tree dest
           || (cm->ts.type == BT_CLASS && CLASS_DATA (cm)->attr.allocatable
               && expr->ts.type != BT_CLASS)))
     {
+      tree size;
+
       gfc_init_se (&se, NULL);
       gfc_conv_expr (&se, expr);
-      tree size;

+      /* The remainder of these instructions follow the if (cm->attr.pointer)
+        if (!cm->attr.dimension) part above.  */
+      gfc_add_block_to_block (&block, &se.pre);
       /* Take care about non-array allocatable components here.  The alloc_*
         routine below is motivated by the alloc_scalar_allocatable_for_
         assignment() routine, but with the realloc portions removed and
         different input.  */
       alloc_scalar_allocatable_subcomponent (&block, dest, cm, expr,
                                             se.string_length);
-      /* The remainder of these instructions follow the if (cm->attr.pointer)
-        if (!cm->attr.dimension) part above.  */
-      gfc_add_block_to_block (&block, &se.pre);

       if (expr->symtree && expr->symtree->n.sym->attr.proc_pointer
          && expr->symtree->n.sym->attr.dummy)
should fix this.  I don't see how code in se.pre could depend on what
alloc_scalar_allocatable_subcomponent emits, and clearly from the #c0 testcase
there can be a dependency in the other direction.

As for the ICE case, this is due to
      if (!expr2->ts.u.cl->backend_decl
          || !VAR_P (expr2->ts.u.cl->backend_decl))
        expr2->ts.u.cl->backend_decl = gfc_create_var (TREE_TYPE (slen),
                                                       "slen");
      gfc_add_modify (block, expr2->ts.u.cl->backend_decl, slen);
expr2->ts.u.cl->backend_decl here is INTEGER_CST and slen is the same
INTEGER_CST (20 in both cases), so changing expr2->ts.u.cl->backend_decl to a
temporary variable pushed into current block is definitely undesirable, it
means references to that slen var can be emitted even before or after the
containing block into which the temporary is pushed using pushdecl.

  parent reply	other threads:[~2024-02-16 12:47 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-19 12:49 [Bug fortran/113503] New: " jakub at gcc dot gnu.org
2024-01-19 12:49 ` [Bug fortran/113503] " jakub at gcc dot gnu.org
2024-01-19 16:59 ` anlauf at gcc dot gnu.org
2024-01-19 17:45 ` anlauf at gcc dot gnu.org
2024-01-20  9:00 ` pinskia at gcc dot gnu.org
2024-01-31 17:21 ` jakub at gcc dot gnu.org
2024-02-16 12:47 ` jakub at gcc dot gnu.org [this message]
2024-02-16 13:24 ` jakub at gcc dot gnu.org
2024-02-17 15:57 ` cvs-commit at gcc dot gnu.org
2024-02-17 16:14 ` 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-113503-4-Tkh8T3lvoG@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).