[Bug fortran/53298] ICE in gfc_conv_scalarized_array_ref for ARRAY + substring

2020-09-09 Thread markeggleston at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53298

--- Comment #14 from markeggleston at gcc dot gnu.org ---
The test case in comment 7 proved trickier to track down.

The ICE occurs in this code:

  /* Components can correspond to fields of different containing
 types, as components are created without context, whereas
 a concrete use of a component has the type of decl as context.
 So, if the type doesn't match, we search the corresponding
 FIELD_DECL in the parent type.  To not waste too much time
 we cache this result in norestrict_decl.
 On the other hand, if the context is a UNION or a MAP (a
 RECORD_TYPE within a UNION_TYPE) always use the given FIELD_DECL.  */

  if (context != TREE_TYPE (decl)
  && !(   TREE_CODE (TREE_TYPE (field)) == UNION_TYPE /* Field is union */
  || TREE_CODE (context) == UNION_TYPE)) /* Field is map */
{
  tree f2 = c->norestrict_decl;
  if (!f2 || DECL_FIELD_CONTEXT (f2) != TREE_TYPE (decl))
==> for (f2 = TYPE_FIELDS (TREE_TYPE (decl)); f2; f2 = DECL_CHAIN (f2))
  if (TREE_CODE (f2) == FIELD_DECL
  && DECL_NAME (f2) == DECL_NAME (field))
break;
  gcc_assert (f2);
  c->norestrict_decl = f2;
  field = f2;
}


The ICE occurs at the line marked with ==>, the assignment f2 = TYPE_FIELDS
(TREE_TYPE (decl)) hides a call to a routine that returns a null pointer which
is then used causing the ICE.

I speculated that the code dealing with f2 should not have been executed. I
noted that in the comments "On the other hand, if the context is a UNION or a
MAP (a RECORD_TYPE within a UNION_TYPE) always use the given FIELD_DECL."  This
does not match the code that follows.

The following change:

trans-expr.c

@@ -2474,8 +2474,8 @@ gfc_conv_component_ref (gfc_se * se, gfc_ref * ref)
  RECORD_TYPE within a UNION_TYPE) always use the given FIELD_DECL.  */

   if (context != TREE_TYPE (decl)
-  && !(   TREE_CODE (TREE_TYPE (field)) == UNION_TYPE /* Field is union */
-   || TREE_CODE (context) == UNION_TYPE)) /* Field is map */
+  && (   TREE_CODE (context) == UNION_TYPE /* Field is union */
+  || TREE_CODE (context) == MAP_TYPE)) /* Field is map */
 {
   tree f2 = c->norestrict_decl;
   if (!f2 || DECL_FIELD_CONTEXT (f2) != TREE_TYPE (decl))

matches the comment and also fixes the ICE for the test case in comment 7.

make -j 8 check-fortran was looking good until test case failures were reported
for:

gfortran.dg/finalize_35.f90
gfortran.dg/finalize_36.f90

[Bug fortran/53298] ICE in gfc_conv_scalarized_array_ref for ARRAY + substring

2020-09-09 Thread markeggleston at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53298

--- Comment #13 from markeggleston at gcc dot gnu.org ---
The test case in comment 0 is fixed by:

trans-array.c

@ -3638,8 +3638,11 @@ gfc_conv_array_ref (gfc_se * se, gfc_array_ref * ar,
gfc_expr *expr,
   /* Handle scalarized references separately.  */
   if (ar->type != AR_ELEMENT)
 {
-  gfc_conv_scalarized_array_ref (se, ar);
-  gfc_advance_se_ss_chain (se);
+  if (se->ss)
+   {
+ gfc_conv_scalarized_array_ref (se, ar);
+ gfc_advance_se_ss_chain (se);
+   }
   return;
 }

make -j 8 check-fortran does not produce any additional test case failures on
x86_64.

The test case in comment 7 still produces the same ICE.

[Bug fortran/53298] ICE in gfc_conv_scalarized_array_ref for ARRAY + substring

2020-07-30 Thread markeggleston at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53298

--- Comment #12 from markeggleston at gcc dot gnu.org ---
Fixed the ICE in comment 5.  I completely missed the "a different ICE"...

More investigation required.

[Bug fortran/53298] ICE in gfc_conv_scalarized_array_ref for ARRAY + substring

2020-07-29 Thread dominiq at lps dot ens.fr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53298

Dominique d'Humieres  changed:

   What|Removed |Added

 Status|RESOLVED|REOPENED
 Resolution|FIXED   |---

--- Comment #11 from Dominique d'Humieres  ---
The original test in comment 0 and the test in commnent 7 are giving an ICE

* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS
(code=1, address=0x0)
frame #0: 0x000100110dd9
f951`::gfc_conv_scalarized_array_ref(se=0x7ffeefbfdfd0,
ar=0x00014560c498) at trans-array.c:3490:14
   3487   int n;
   3488 
   3489   ss = se->ss;
-> 3490   expr = ss->info->expr;
   3491   info = >info->data.array;
   3492   if (ar)
   3493 n = se->loop->order[0];
Target 0: (f951) stopped.

because ss is NULL:

(gfc_se) $5 = {
  pre = {
head = 0x
has_scope = 0
  }
  post = {
head = 0x
has_scope = 0
  }
  expr = 0x000142fb3ea0
  string_length = 0x
  class_vptr = 0x
  descriptor_only = 0
  want_pointer = 0
  direct_byref = 0
  byref_noassign = 0
  ignore_optional = 0
  data_not_needed = 0
  no_function_call = 0
  force_tmp = 0
  force_no_tmp = 0
  use_offset = 0
  want_coarray = 0
  parent = 0x7ffeefbfe7c0
  ss = 0x
  loop = 0x
}

[Bug fortran/53298] ICE in gfc_conv_scalarized_array_ref for ARRAY + substring

2020-07-29 Thread markeggleston at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53298

markeggleston at gcc dot gnu.org changed:

   What|Removed |Added

 CC||markeggleston at gcc dot 
gnu.org
 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--- Comment #10 from markeggleston at gcc dot gnu.org ---
Committed to master.

[Bug fortran/53298] ICE in gfc_conv_scalarized_array_ref for ARRAY + substring

2020-07-29 Thread cvs-commit at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53298

--- Comment #9 from CVS Commits  ---
The master branch has been updated by Mark Eggleston
:

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

commit r11-2398-gc2e99836a2751b6d970ca6e50c1a368f5d2a2375
Author: Mark Eggleston 
Date:   Fri Jul 17 14:22:48 2020 +0100

Fortran  : ICE in gfc_conv_scalarized_array_ref PR53298

When an array of characters is an argument to a subroutine and
is accessed using (:)(1:) an ICE occurs.  The upper bound of the
substring does not have an expression and such should not have
a Scalarization State structure added to the Scalarization State
chain.

2020-07-29  Mark Eggleston  

gcc/fortran/

PR fortran/53298
* trans-array.c (gfc_walk_array_ref): If ref->ss.end is set
call gfc_get_scalar_ss.

2020-07-29  Mark Eggleston  

gcc/testsuite/

PR fortran/53298
* gfortran.dg/pr53298.f90: New test.

[Bug fortran/53298] ICE in gfc_conv_scalarized_array_ref for ARRAY + substring

2020-07-23 Thread bardeau at iram dot fr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53298

--- Comment #8 from Sebastien Bardeau  ---
I am experiencing an ICE looking pretty much the same as this one.

gfortran version and messages:

bardeau ~> gfortran -v
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/home/bardeau/Softs/gcc-10.1.0/libexec/gcc/x86_64-pc-linux-gnu/10.1.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../srcdir/configure --with-gmp=/home/bardeau/Softs/gcc-deps
--prefix=/home/bardeau/Softs/gcc-10.1.0 --enable-languages=c,c++,fortran
--disable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 10.1.0 (GCC) 

bardeau ~> gfortran -c ice.f90 
ice.f90:21:0:

   21 | t = a(1)%c(1:l).eq.b%d(1:l)
  | 
internal compiler error: Segmentation fault
0xbaf7ff crash_signal
../../srcdir/gcc/toplev.c:328
0x6f8c06 gfc_conv_scalarized_array_ref
../../srcdir/gcc/fortran/trans-array.c:3490
0x6fb19c gfc_conv_array_ref(gfc_se*, gfc_array_ref*, gfc_expr*, locus*)
../../srcdir/gcc/fortran/trans-array.c:3641
0x7265ae gfc_conv_variable
../../srcdir/gcc/fortran/trans-expr.c:2827
0x7229ee gfc_conv_expr_op
../../srcdir/gcc/fortran/trans-expr.c:3620
0x7229ee gfc_conv_expr(gfc_se*, gfc_expr*)
../../srcdir/gcc/fortran/trans-expr.c:8672
0x72aebb gfc_trans_assignment_1
../../srcdir/gcc/fortran/trans-expr.c:10878
0x6f2933 trans_code
../../srcdir/gcc/fortran/trans.c:1864
0x71bb74 gfc_generate_function_code(gfc_namespace*)
../../srcdir/gcc/fortran/trans-decl.c:6835
0x6f63a1 gfc_generate_module_code(gfc_namespace*)
../../srcdir/gcc/fortran/trans.c:2264
0x6987b5 translate_all_program_units
../../srcdir/gcc/fortran/parse.c:6293
0x6987b5 gfc_parse_file()
../../srcdir/gcc/fortran/parse.c:6545
0x6efa7f gfc_be_parse_file
../../srcdir/gcc/fortran/f95-lang.c:210
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See  for instructions.

[Bug fortran/53298] ICE in gfc_conv_scalarized_array_ref for ARRAY + substring

2020-07-23 Thread bardeau at iram dot fr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53298

Sebastien Bardeau  changed:

   What|Removed |Added

 CC||bardeau at iram dot fr

--- Comment #7 from Sebastien Bardeau  ---
Created attachment 48919
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48919=edit
ICE in gfc_conv_scalarized_array_ref

Example code producing an ICE in gfc_conv_scalarized_array_ref

[Bug fortran/53298] ICE in gfc_conv_scalarized_array_ref for ARRAY + substring

2019-03-17 Thread dominiq at lps dot ens.fr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53298

--- Comment #6 from Dominique d'Humieres  ---
The tests in comment 0 and 5 compile if I replace '(1:)' with something such as
'(1:3)'.

[Bug fortran/53298] ICE in gfc_conv_scalarized_array_ref for ARRAY + substring

2018-03-25 Thread anlauf at gmx dot de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53298

--- Comment #5 from Harald Anlauf  ---
Removing the size() in the print and the unneeded declaration of ,
one gets a different ICE:

  character(len=5) :: str(3)
  call f(str(:))
contains
  subroutine f(x)
   character(len=*) :: x(:)
   print *,  x(:)(1:)
  end subroutine f
end

Program received signal SIGSEGV, Segmentation fault.
gfc_conv_expr (se=0xbfffe134, expr=0x0)
at ../../trunk/gcc/fortran/trans-expr.c:7891
7891  if (expr->ts.type == BT_DERIVED && expr->ts.u.derived->ts.f90_type ==
BT_VOID

(gdb) print expr
$2 = (gfc_expr *) 0x0

[Bug fortran/53298] ICE in gfc_conv_scalarized_array_ref for ARRAY + substring

2018-01-18 Thread anlauf at gmx dot de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53298

Harald Anlauf  changed:

   What|Removed |Added

 CC||anlauf at gmx dot de

--- Comment #4 from Harald Anlauf  ---
Still there at 8-trunk rev.256858, now line

3383  expr = ss->info->expr;

(gdb) print ss
$1 = (gfc_ss *) 0x0

[Bug fortran/53298] ICE in gfc_conv_scalarized_array_ref for ARRAY + substring

2017-11-12 Thread tkoenig at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53298

--- Comment #3 from Thomas Koenig  ---
Paul, is this something that could be fixed with the
new descriptor you introduced?

[Bug fortran/53298] ICE in gfc_conv_scalarized_array_ref for ARRAY + substring

2013-04-27 Thread dominiq at lps dot ens.fr


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53298



Dominique d'Humieres dominiq at lps dot ens.fr changed:



   What|Removed |Added



 Status|UNCONFIRMED |NEW

   Last reconfirmed||2013-04-27

 Ever Confirmed|0   |1



--- Comment #2 from Dominique d'Humieres dominiq at lps dot ens.fr 2013-04-27 
13:31:04 UTC ---

The ICE occurs also with the fortran-dev branch (r198346 with the patch at

http://gcc.gnu.org/ml/fortran/2013-04/msg00237.html).


[Bug fortran/53298] ICE in gfc_conv_scalarized_array_ref for ARRAY + substring

2013-04-06 Thread tkoenig at gcc dot gnu.org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53298



Thomas Koenig tkoenig at gcc dot gnu.org changed:



   What|Removed |Added



 Blocks||56818



--- Comment #1 from Thomas Koenig tkoenig at gcc dot gnu.org 2013-04-06 
11:46:37 UTC ---

Also looks like something that we could include with the array descritor

reform.