Bug 77667 - ICE in expand_call, at calls.c:2588
Summary: ICE in expand_call, at calls.c:2588
Status: RESOLVED DUPLICATE of bug 67804
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 7.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2016-09-20 17:58 UTC by Gerhard Steinmetz
Modified: 2022-01-16 20:48 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 4.5.4
Known to fail: 4.6.0
Last reconfirmed: 2021-07-24 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gerhard Steinmetz 2016-09-20 17:58:13 UTC
With invalid code :


$ cat z1.f90
program p
   type t
      integer :: a
      integer, pointer :: b
   end type
   type(t) :: x
   data x /t(4, nul())/
   print *, x%a, associated(x%b)
end


$ gfortran-7-20160918 z1.f90
z1.f90:9:0:

 end

internal compiler error: Segmentation fault
0xc21a5f crash_signal
        ../../gcc/toplev.c:336
0x7eea98 expand_call(tree_node*, rtx_def*, int)
        ../../gcc/calls.c:2588
0x9058ac expand_expr_real_1(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**, bool)
        ../../gcc/expr.c:10737
0xf092a3 expand_expr
        ../../gcc/expr.h:279
0xf092a3 output_constant
        ../../gcc/varasm.c:4758
0xf0a311 output_constant
        ../../gcc/varasm.c:4665
0xf0a311 output_constructor_regular_field
        ../../gcc/varasm.c:5018
0xf0a311 output_constructor
        ../../gcc/varasm.c:5288
0xf0bbb4 output_constant
        ../../gcc/varasm.c:4665
0xf0bbb4 assemble_variable_contents
        ../../gcc/varasm.c:2074
0xf133f9 assemble_variable(tree_node*, int, int, int)
        ../../gcc/varasm.c:2250
0xf18be8 varpool_node::assemble_decl()
        ../../gcc/varpool.c:589
0x83ee1b output_in_order
        ../../gcc/cgraphunit.c:2232
0x83f1fd symbol_table::compile()
        ../../gcc/cgraphunit.c:2472
0x841c52 symbol_table::compile()
        ../../gcc/cgraphunit.c:2542
0x841c52 symbol_table::finalize_compilation_unit()
        ../../gcc/cgraphunit.c:2568

---


Older releases give :


$ gfortran-6 z1.f90
z1.f90:9:0:

 end

internal compiler error: Segmentation fault


$ gfortran-5 z1.f90
z1.f90:9:0:

 end
 ^
internal compiler error: in gen_reg_rtx, at emit-rtl.c:1059


$ gfortran-4.9 z1.f90
z1.f90:9:0: internal compiler error: in gen_reg_rtx, at emit-rtl.c:866
 end
 ^
Please submit a full bug report,
with preprocessed source if appropriate.
Comment 1 Gerhard Steinmetz 2016-09-20 18:00:40 UTC
Variants with a type mismatch give a suboptimal error message :


$ cat z2.f90
program p
   type t
      integer :: a
      integer, pointer :: b
   end type
   type(t) :: x
   data x /t(4, f())/
   print *, x%a, associated(x%b)
end


$ cat z3.f90
program p
   type t
      integer :: a
      logical, pointer :: b
   end type
   type(t) :: x
   data x /t(4, f())/
   print *, x%a, associated(x%b)
end


$ gfortran-7-20160918 z3.f90
z3.f90:9:0:

 end

Error: initializer for floating value is not a floating constant
Comment 2 Martin Liška 2016-09-20 20:37:15 UTC
Started with 4.6.0, ICE messages are various, as reported.
Comment 3 anlauf 2022-01-04 21:49:56 UTC
The following patch seems to work:

diff --git a/gcc/fortran/data.c b/gcc/fortran/data.c
index 839e04277ef..dee38e5de50 100644
--- a/gcc/fortran/data.c
+++ b/gcc/fortran/data.c
@@ -589,6 +589,15 @@ gfc_assign_data_value (gfc_expr *lvalue, gfc_expr *rvalue, mpz_t index,
        return false;
     }
 
+  if (rvalue->symtree && rvalue->symtree->n.sym
+      && !rvalue->symtree->n.sym->attr.target
+      && !gfc_is_constant_expr (rvalue))
+    {
+      gfc_error ("non-constant initialization expression in DATA statement "
+                "at %L", &rvalue->where);
+      return false;
+    }
+
   if (ref || (last_ts->type == BT_CHARACTER
              && rvalue->expr_type == EXPR_CONSTANT))
     {
Comment 4 anlauf 2022-01-04 22:07:34 UTC
(In reply to anlauf from comment #3)
> The following patch seems to work:
... and regtests ok.

It is not really pretty, though, and does not help with apparently related PRs,
such as PR50410.
Comment 5 anlauf 2022-01-14 21:31:51 UTC
Seems fixed on mainline for gcc-12.

Most likely fix: r12-6557 for pr67804.
Comment 6 anlauf 2022-01-16 20:48:53 UTC
Indeed fixed on mainline by r12-6557.

*** This bug has been marked as a duplicate of bug 67804 ***