public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/93685] [9/10 Regression] ICE in gfc_constructor_append_expr, at fortran/constructor.c:135
       [not found] <bug-93685-4@http.gcc.gnu.org/bugzilla/>
@ 2020-03-12 11:58 ` jakub at gcc dot gnu.org
  2020-12-19 22:08 ` [Bug fortran/93685] [9/10/11 " anlauf at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-03-12 11:58 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|9.3                         |9.4

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 9.3.0 has been released, adjusting target milestone.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug fortran/93685] [9/10/11 Regression] ICE in gfc_constructor_append_expr, at fortran/constructor.c:135
       [not found] <bug-93685-4@http.gcc.gnu.org/bugzilla/>
  2020-03-12 11:58 ` [Bug fortran/93685] [9/10 Regression] ICE in gfc_constructor_append_expr, at fortran/constructor.c:135 jakub at gcc dot gnu.org
@ 2020-12-19 22:08 ` anlauf at gcc dot gnu.org
  2020-12-20 21:26 ` anlauf at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: anlauf at gcc dot gnu.org @ 2020-12-19 22:08 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-valid-code
                 CC|                            |anlauf at gcc dot gnu.org

--- Comment #3 from anlauf at gcc dot gnu.org ---
(In reply to markeggleston from comment #1)
> I think the issues of error messages and -std can be postponed until the
> next release.

The current status is that

program p
  type u
     integer,   pointer :: i
  end type u
  type(u) :: y
  integer  , target :: i = 10
  data y%i /i/
  print *, y%i
end

works with current master, while the (valid) code

program p
  type t
     character, pointer :: a
  end type t
  type(t) :: x
  character, target :: c = 'c'
  data x%a /c/
  print *, x%a
end

still ICEs the same as the (invalid) testcase in comment#0.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug fortran/93685] [9/10/11 Regression] ICE in gfc_constructor_append_expr, at fortran/constructor.c:135
       [not found] <bug-93685-4@http.gcc.gnu.org/bugzilla/>
  2020-03-12 11:58 ` [Bug fortran/93685] [9/10 Regression] ICE in gfc_constructor_append_expr, at fortran/constructor.c:135 jakub at gcc dot gnu.org
  2020-12-19 22:08 ` [Bug fortran/93685] [9/10/11 " anlauf at gcc dot gnu.org
@ 2020-12-20 21:26 ` anlauf at gcc dot gnu.org
  2020-12-20 21:58 ` anlauf at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: anlauf at gcc dot gnu.org @ 2020-12-20 21:26 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from anlauf at gcc dot gnu.org ---
A first attempt to fix the character / non-character issue seem to require
a replacement of the following hunk from

commit eb401400f59e4d1f28bbdc788c3234e0968081d7
Author: Andre Vehreschild <vehre@gcc.gnu.org>
Date:   Wed Dec 14 12:52:09 2016 +0100

    re PR fortran/78672 (Gfortran test suite failures with a sanitized
compiler)


diff --git a/gcc/fortran/data.c b/gcc/fortran/data.c
index 139ce880534..ea19732ccc3 100644
--- a/gcc/fortran/data.c
+++ b/gcc/fortran/data.c
@@ -483,7 +483,10 @@ gfc_assign_data_value (gfc_expr *lvalue, gfc_expr *rvalue,
mpz_t index,

   if (ref || last_ts->type == BT_CHARACTER)
     {
-      if (lvalue->ts.u.cl->length == NULL && !(ref && ref->u.ss.length !=
NULL))
+      /* An initializer has to be constant.  */
+      if (rvalue->expr_type != EXPR_CONSTANT
+         || (lvalue->ts.u.cl->length == NULL
+             && !(ref && ref->u.ss.length != NULL)))
        return false;
       expr = create_character_initializer (init, last_ts, ref, rvalue);
     }

by

diff --git a/gcc/fortran/data.c b/gcc/fortran/data.c
index 3e52a5717b5..76ddd9dab7f 100644
--- a/gcc/fortran/data.c
+++ b/gcc/fortran/data.c
@@ -546,12 +546,11 @@ gfc_assign_data_value (gfc_expr *lvalue, gfc_expr
*rvalue, mpz_t index,
        return false;
     }

-  if (ref || last_ts->type == BT_CHARACTER)
+  if (ref || (last_ts->type == BT_CHARACTER
+             && rvalue->expr_type == EXPR_CONSTANT))
     {
       /* An initializer has to be constant.  */
-      if (rvalue->expr_type != EXPR_CONSTANT
-         || (lvalue->ts.u.cl->length == NULL
-             && !(ref && ref->u.ss.length != NULL)))
+      if (lvalue->ts.u.cl->length == NULL && !(ref && ref->u.ss.length !=
NULL))
        return false;
       expr = create_character_initializer (init, last_ts, ref, rvalue);
     }

which fixes the ICE to the second testcase in comment#3.
However, it changes the traceback for comment#0 to:

pr93685.f90:1:9:

    1 | program p
      |         1
internal compiler error: in gfc_conv_string_init, at fortran/trans-const.c:148
0x79a56a gfc_conv_string_init(tree_node*, gfc_expr*)
        ../../gcc-trunk/gcc/fortran/trans-const.c:148
0x7c735f gfc_conv_initializer(gfc_expr*, gfc_typespec*, tree_node*, bool, bool,
bool)
        ../../gcc-trunk/gcc/fortran/trans-expr.c:7883
0x7c79e6 gfc_conv_structure(gfc_se*, gfc_expr*, int)
        ../../gcc-trunk/gcc/fortran/trans-expr.c:8754
0x7c7391 gfc_conv_initializer(gfc_expr*, gfc_typespec*, tree_node*, bool, bool,
bool)
        ../../gcc-trunk/gcc/fortran/trans-expr.c:7876
0x7a7f2a gfc_get_symbol_decl(gfc_symbol*)
        ../../gcc-trunk/gcc/fortran/trans-decl.c:1917
0x7aba8f generate_local_decl
        ../../gcc-trunk/gcc/fortran/trans-decl.c:5950
0x75bf12 do_traverse_symtree
        ../../gcc-trunk/gcc/fortran/symbol.c:4171
0x7acfcc generate_local_vars
        ../../gcc-trunk/gcc/fortran/trans-decl.c:6156
0x7acfcc gfc_generate_function_code(gfc_namespace*)
        ../../gcc-trunk/gcc/fortran/trans-decl.c:6815
0x724cc7 translate_all_program_units
        ../../gcc-trunk/gcc/fortran/parse.c:6351
0x724cc7 gfc_parse_file()
        ../../gcc-trunk/gcc/fortran/parse.c:6620
0x77187f gfc_be_parse_file
        ../../gcc-trunk/gcc/fortran/f95-lang.c:212

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug fortran/93685] [9/10/11 Regression] ICE in gfc_constructor_append_expr, at fortran/constructor.c:135
       [not found] <bug-93685-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2020-12-20 21:26 ` anlauf at gcc dot gnu.org
@ 2020-12-20 21:58 ` anlauf at gcc dot gnu.org
  2020-12-20 22:16 ` anlauf at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: anlauf at gcc dot gnu.org @ 2020-12-20 21:58 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from anlauf at gcc dot gnu.org ---
The following seems to do the latter job:

diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index bfe08be2a94..f66afab85d1 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -7877,12 +7877,14 @@ gfc_conv_initializer (gfc_expr * expr, gfc_typespec *
ts, tree type,
          return se.expr;

        case BT_CHARACTER:
-         {
-           tree ctor = gfc_conv_string_init (ts->u.cl->backend_decl,expr);
-           TREE_STATIC (ctor) = 1;
-           return ctor;
-         }
+         if (expr->expr_type == EXPR_CONSTANT)
+           {
+             tree ctor = gfc_conv_string_init (ts->u.cl->backend_decl, expr);
+             TREE_STATIC (ctor) = 1;
+             return ctor;
+           }

+         /* Fallthrough.  */
        default:
          gfc_init_se (&se, NULL);
          gfc_conv_constant (&se, expr);

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug fortran/93685] [9/10/11 Regression] ICE in gfc_constructor_append_expr, at fortran/constructor.c:135
       [not found] <bug-93685-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2020-12-20 21:58 ` anlauf at gcc dot gnu.org
@ 2020-12-20 22:16 ` anlauf at gcc dot gnu.org
  2020-12-27 19:36 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: anlauf at gcc dot gnu.org @ 2020-12-20 22:16 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |anlauf at gcc dot gnu.org
             Status|NEW                         |ASSIGNED

--- Comment #6 from anlauf at gcc dot gnu.org ---
Patch submitted:
https://gcc.gnu.org/pipermail/fortran/2020-December/055452.html

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug fortran/93685] [9/10/11 Regression] ICE in gfc_constructor_append_expr, at fortran/constructor.c:135
       [not found] <bug-93685-4@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2020-12-20 22:16 ` anlauf at gcc dot gnu.org
@ 2020-12-27 19:36 ` cvs-commit at gcc dot gnu.org
  2020-12-29 20:28 ` cvs-commit at gcc dot gnu.org
  2020-12-29 20:32 ` anlauf at gcc dot gnu.org
  7 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-12-27 19:36 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Harald Anlauf
<anlauf@gcc.gnu.org>:

https://gcc.gnu.org/g:435e0cd4a06db5bdc5fc057e8cc7db21f4b3b421

commit r10-9177-g435e0cd4a06db5bdc5fc057e8cc7db21f4b3b421
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Fri Dec 25 15:40:39 2020 +0100

    PR fortran/93685 - ICE in gfc_constructor_append_expr, at
fortran/constructor.c:135

    Fix handling of F2018 enhancements to DATA statements that allows
    initialization of pointer components to derived types, and adjust error
    handling for the CHARACTER case.

    gcc/fortran/ChangeLog:

            * data.c (gfc_assign_data_value): Restrict use of
            create_character_initializer to constant initializers.
            * trans-expr.c (gfc_conv_initializer): Ensure that character
            initializer is constant, otherwise fall through to get the same
            error handling as for non-character cases.

    gcc/testsuite/ChangeLog:

            * gfortran.dg/pr93685_1.f90: New test.
            * gfortran.dg/pr93685_2.f90: New test.

    (cherry picked from commit 6e36772ba6a8173318c173508bd3254e4140b726)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug fortran/93685] [9/10/11 Regression] ICE in gfc_constructor_append_expr, at fortran/constructor.c:135
       [not found] <bug-93685-4@http.gcc.gnu.org/bugzilla/>
                   ` (5 preceding siblings ...)
  2020-12-27 19:36 ` cvs-commit at gcc dot gnu.org
@ 2020-12-29 20:28 ` cvs-commit at gcc dot gnu.org
  2020-12-29 20:32 ` anlauf at gcc dot gnu.org
  7 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-12-29 20:28 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-9 branch has been updated by Harald Anlauf
<anlauf@gcc.gnu.org>:

https://gcc.gnu.org/g:fe37f4aac179e8a7489fa5492dd56dce95f094b2

commit r9-9141-gfe37f4aac179e8a7489fa5492dd56dce95f094b2
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Fri Dec 25 15:40:39 2020 +0100

    PR fortran/93685 - ICE in gfc_constructor_append_expr, at
fortran/constructor.c:135

    Fix handling of F2018 enhancements to DATA statements that allows
    initialization of pointer components to derived types, and adjust error
    handling for the CHARACTER case.

    gcc/fortran/ChangeLog:

            * data.c (gfc_assign_data_value): Restrict use of
            create_character_initializer to constant initializers.
            * trans-expr.c (gfc_conv_initializer): Ensure that character
            initializer is constant, otherwise fall through to get the same
            error handling as for non-character cases.

    gcc/testsuite/ChangeLog:

            * gfortran.dg/pr93685_1.f90: New test.
            * gfortran.dg/pr93685_2.f90: New test.

    (cherry picked from commit 6e36772ba6a8173318c173508bd3254e4140b726)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug fortran/93685] [9/10/11 Regression] ICE in gfc_constructor_append_expr, at fortran/constructor.c:135
       [not found] <bug-93685-4@http.gcc.gnu.org/bugzilla/>
                   ` (6 preceding siblings ...)
  2020-12-29 20:28 ` cvs-commit at gcc dot gnu.org
@ 2020-12-29 20:32 ` anlauf at gcc dot gnu.org
  7 siblings, 0 replies; 8+ messages in thread
From: anlauf at gcc dot gnu.org @ 2020-12-29 20:32 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #9 from anlauf at gcc dot gnu.org ---
Fixed on master for gcc-11, and on 10- and 9-branches.

Due to a glitch in the commit message for master no automatic commit message
was attached to this PR.  This was manually corrected for the branches.

Thanks for the report!

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-12-29 20:32 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-93685-4@http.gcc.gnu.org/bugzilla/>
2020-03-12 11:58 ` [Bug fortran/93685] [9/10 Regression] ICE in gfc_constructor_append_expr, at fortran/constructor.c:135 jakub at gcc dot gnu.org
2020-12-19 22:08 ` [Bug fortran/93685] [9/10/11 " anlauf at gcc dot gnu.org
2020-12-20 21:26 ` anlauf at gcc dot gnu.org
2020-12-20 21:58 ` anlauf at gcc dot gnu.org
2020-12-20 22:16 ` anlauf at gcc dot gnu.org
2020-12-27 19:36 ` cvs-commit at gcc dot gnu.org
2020-12-29 20:28 ` cvs-commit at gcc dot gnu.org
2020-12-29 20:32 ` anlauf at gcc dot gnu.org

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).