[Bug fortran/47425] Array constructor with type-spec: Fails with more complicated length type expr

2018-09-03 Thread gs...@t-online.de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47425

G. Steinmetz  changed:

   What|Removed |Added

 CC||gs...@t-online.de

--- Comment #5 from G. Steinmetz  ---

Starting again from a simple test file :

$ cat za.f90
program p
   integer, parameter :: n = 1
   print *, [character(n) :: 'a']
end

$ gfortran-9-20180902 -c za.f90 -fdump-tree-original



Modifying from a constant/parameter n to a variable n
(or an expression with a variable), and dumping again :

$ cat zb.f90
program p
   integer :: n = 1
   print *, [character(n) :: 'a']
end

$ gfortran-9-20180902 -c zb.f90 -fdump-tree-original
zb.f90:3:0:

3 |print *, [character(n) :: 'a']
  |
Error: size of variable 'A.1' is too large



Comparing the dumps :
{
  ...
{
  static character(kind=1)[1:1] * A.1[1] = {&"a"[1]{lb: 1 sz: 1}};
  ...
_gfortran_transfer_character_write (_parm.0, A.1[S.2], 1);

versus :
{
  static integer(kind=4) n = 1;
  ...
{
  integer(kind=8) D.3770;
  static character(kind=1) A.1[1][1:D.3770] = {"a"};
  D.3770 = (integer(kind=8)) MAX_EXPR ;
  ...
_gfortran_transfer_character_write (_parm.0, [S.2], D.3770);


Helper variable D.3770 is used to define A.1, before being initialized.
What could be done to swap the two relevant lines ?
(pseudo code) :

  integer(kind=8) D.3770;
  D.3770 = (integer(kind=8)) MAX_EXPR ;
  static character(kind=1) A.1[1][1:D.3770] = {"a"};

[Bug fortran/47425] Array constructor with type-spec: Fails with more complicated length type expr

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

--- Comment #4 from Gerhard Steinmetz  
---
Some simplifications :


$ cat z1.f90
program p
   character(3) :: x
   integer :: n = 3
   print *, [character(len(x(1:n))) :: 'a']
end


$ gfortran-7-20160703 z1.f90
z1.f90:4:0:

print *, [character(len(x(1:n))) :: 'a']

Error: size of variable 'A.1' is too large

---


$ cat z2.f90
program p
   character(3) :: x
   print *, [character(len(x(1:3))) :: 'a', 'b']
end


$ gfortran-7-20160703 z2.f90
z2.f90:4:0:

 end

internal compiler error: in output_constructor_regular_field, at varasm.c:4979
0xef0ac5 output_constructor_regular_field
../../gcc/varasm.c:4979
0xef0ac5 output_constructor
../../gcc/varasm.c:5287
0xef0e64 output_constant
../../gcc/varasm.c:4664
0xef0e64 assemble_variable_contents
../../gcc/varasm.c:2073
0xef8619 assemble_variable(tree_node*, int, int, int)
../../gcc/varasm.c:2249
0xefde08 varpool_node::assemble_decl()
../../gcc/varpool.c:589
0x8363c3 output_in_order
../../gcc/cgraphunit.c:2232
0x83674d symbol_table::compile()
../../gcc/cgraphunit.c:2469
0x8391a2 symbol_table::compile()
../../gcc/cgraphunit.c:2539
0x8391a2 symbol_table::finalize_compilation_unit()
../../gcc/cgraphunit.c:2565

---


$ cat z3.f90
program p
   character(3) :: x
   print *, [character(len(x(:))) :: 'a', 'b']
end


$ gfortran-7-20160703 z3.f90
$ a.out
 a  b

---


$ cat z1_parameter.f90
program p
   character(3) :: x
   integer, parameter :: n = 3
   print *, [character(len(x(1:n))) :: 'a']
end


$ gfortran-7-20160703 z1_parameter.f90
$ a.out
 a

---


$ cat z4.f90
program p
   character(3) :: x
   integer, parameter :: n = 3
   print *, [character(len(x(1:n))) :: 'a', 'b']
end


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

 end

internal compiler error: in output_constructor_regular_field, at varasm.c:4979
#...

[Bug fortran/47425] Array constructor with type-spec: Fails with more complicated length type expr

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

Gerhard Steinmetz  changed:

   What|Removed |Added

 CC||gerhard.steinmetz.fortran@t
   ||-online.de

--- Comment #3 from Gerhard Steinmetz  
---
Together with -flto :

$ gfortran-7-20160703 -flto -c pr47425.f90
pr47425.f90:7:0: internal compiler error: tree code 'ssa_name' is not supported
in LTO streams
 end

0xada461 DFS::DFS(output_block*, tree_node*, bool, bool, bool)
../../gcc/lto-streamer-out.c:676
0xadba6d lto_output_tree(output_block*, tree_node*, bool, bool)
../../gcc/lto-streamer-out.c:1616
0xacfd7f write_global_stream
../../gcc/lto-streamer-out.c:2418
0xad969e lto_output_decl_state_streams(output_block*, lto_out_decl_state*)
../../gcc/lto-streamer-out.c:2465
0xad969e produce_asm_for_decls()
../../gcc/lto-streamer-out.c:2836
0xb4138f write_lto
../../gcc/passes.c:2455
0xb44d3e ipa_write_summaries_1
../../gcc/passes.c:2516
0xb44d3e ipa_write_summaries()
../../gcc/passes.c:2576
0x83694f ipa_passes
../../gcc/cgraphunit.c:2311
0x83694f symbol_table::compile()
../../gcc/cgraphunit.c:2405
0x8391a2 symbol_table::compile()
../../gcc/cgraphunit.c:2539
0x8391a2 symbol_table::finalize_compilation_unit()
../../gcc/cgraphunit.c:2565

[Bug fortran/47425] Array constructor with type-spec: Fails with more complicated length type expr

2013-07-15 Thread burnus at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47425

Tobias Burnus burnus at gcc dot gnu.org changed:

   What|Removed |Added

   Keywords||ice-on-valid-code

--- Comment #2 from Tobias Burnus burnus at gcc dot gnu.org ---
Another example. Note in particular the case n==0. The following program should
print:

::
a:d:f
ab:de:fg
abc:de :fgh

It does so with ifort (and except for n==0 also with crayftn). However, with
gfortran one gets at compile time:
   error: size of variable 'A.1' is too large

subroutine test(n)
  integer :: n
  print '(3(a::))', [ character(len=n) :: abc, de, fghijkl ]
end subroutine
call test(0)
call test(1)
call test(2)
call test(3)
end


[Bug fortran/47425] Array constructor with type-spec: Fails with more complicated length type expr

2011-06-30 Thread dominiq at lps dot ens.fr
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47425

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

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2011.06.30 19:41:43
 Ever Confirmed|0   |1

--- Comment #1 from Dominique d'Humieres dominiq at lps dot ens.fr 2011-06-30 
19:41:43 UTC ---
Still there at revision 175707 (trunk).