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

gscfq@t-online.de gcc-bugzilla@gcc.gnu.org
Mon Sep 3 18:34:00 GMT 2018


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

G. Steinmetz <gscfq@t-online.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |gscfq@t-online.de

--- Comment #5 from G. Steinmetz <gscfq@t-online.de> ---

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 (&dt_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 <n, 0>;
      ...
            _gfortran_transfer_character_write (&dt_parm.0, &A.1[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 <n, 0>;
      static character(kind=1) A.1[1][1:D.3770] = {"a"};


More information about the Gcc-bugs mailing list