[Bug fortran/71936] ICE in wide_int_to_tree, at tree.c:1487

2016-07-19 Thread gerhard.steinmetz.fort...@t-online.de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71936

--- Comment #2 from Gerhard Steinmetz  
---

To get the whole picture it's necessary to take a look at four
analogous cases with "type" instead of "class". They compile without
an error (v6/v7), but occationally run for a long time (y3/y4).


$ cat y1.f90
program p
   type t
   end type
   type(t), allocatable :: x(:)
   allocate (x, mold=f())
   deallocate (x)
   allocate (x, source=f())
contains
   function f()
  type(t), allocatable :: f(:)
   end
end


$ cat y2.f90
program p
   type t
   end type
   type(t), allocatable :: x(:)
   allocate (x, mold=f())
   deallocate (x)
   allocate (x, source=f())
contains
   function f()
  type(t), pointer :: f(:)
   end
end


$ cat y3.f90
program p
   type t
   end type
   type(t), pointer :: x(:)
   allocate (x, mold=f())
   deallocate (x)
   allocate (x, source=f())
contains
   function f()
  type(t), allocatable :: f(:)
   end
end


$ cat y4.f90
program p
   type t
   end type
   type(t), pointer :: x(:)
   allocate (x, mold=f())
   deallocate (x)
   allocate (x, source=f())
contains
   function f()
  type(t), pointer :: f(:)
   end
end



$ gfortran-5 y4.f90
y4.f90:5:13:

allocate (x, mold=f())
 1
Error: Array specification required in ALLOCATE statement at (1)
y4.f90:7:13:

allocate (x, source=f())
 1
Error: Array specification required in ALLOCATE statement at (1)
$


$ gfortran-7-20160717 y4.f90
$
$ time timeout 100.0 a.out

real1m40.002s
user1m40.046s
sys 0m0.003s

[Bug fortran/71936] ICE in wide_int_to_tree, at tree.c:1487

2016-07-19 Thread gerhard.steinmetz.fort...@t-online.de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71936

--- Comment #1 from Gerhard Steinmetz  
---
These other two cases produce an related ICE :


$ cat z3.f90
program p
   type t
   end type
   class(t), pointer :: x(:)
   allocate (x, mold=f())
   deallocate (x)
   allocate (x, source=f())
contains
   function f()
  class(t), allocatable :: f(:)
   end
end


$ cat z4.f90
program p
   type t
   end type
   class(t), pointer :: x(:)
   allocate (x, mold=f())
   deallocate (x)
   allocate (x, source=f())
contains
   function f()
  class(t), pointer :: f(:)
   end
end



$ gfortran-7-20160717 z4.f90
z4.f90:5:0:

allocate (x, mold=f())

internal compiler error: in fold_convert_loc, at fold-const.c:2370
0x943a0c fold_convert_loc(unsigned int, tree_node*, tree_node*)
../../gcc/fold-const.c:2370
0x71f6a4 gfc_allocate_using_malloc(stmtblock_t*, tree_node*, tree_node*,
tree_node*)
../../gcc/fortran/trans.c:663
0x7a0b70 gfc_trans_allocate(gfc_code*)
../../gcc/fortran/trans-stmt.c:5878
0x71c407 trans_code
../../gcc/fortran/trans.c:1838
0x74b218 gfc_generate_function_code(gfc_namespace*)
../../gcc/fortran/trans-decl.c:6207
0x6d6cc0 translate_all_program_units
../../gcc/fortran/parse.c:5916
0x6d6cc0 gfc_parse_file()
../../gcc/fortran/parse.c:6122
0x719192 gfc_be_parse_file
../../gcc/fortran/f95-lang.c:198