This is the mail archive of the mailing list for the GNU Fortran project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PR 19925 and expansion of array constructors

I've been looking at PR 19925.  The bug reported in the PR is
that large implied do loops in initialisation expressions doesn't
work; the code

program stuff
    integer :: i_do
    integer :: i(101) = (/ (i_do, i_do=1,101) /)
    write (*,*) i
end program stuff

gives an ICE.  However, if the size of the array i is reduced to
100 it does work.  The reason for this is that the function
gfc_expand_constructor in array.c only expands constructors up to
a size of GFC_MAX_AC_EXPAND, which is defined to be 100.  Then,
in the function gfc_conv_array_initializer (in trans-array.c), we
have the following code:

if (c->iterator)
    /* Problems occur when we get something like
       integer :: a(lots) = (/(i, i=1,lots)/)  */
    /* TODO: Unexpanded array initializers.  */
       ("Possible frontend bug: array constructor not expanded");

The TODO comment indicates that the expansion should be made
here.  The comment that introduces gfc_conv_array_initializer,
however, says

/* Create an array constructor from an initialization expression.
   We assume the frontend already did any expansions and conversions.  */

which indicates that the constructors should have been expanded
_before_ we get here.  

My question is: where is the correct place to expand the
constructor?  And why not expand all constructors, small as well as
large, in gfc_expand_constructor?  Since they'll have to be
eaxpanded anyway at some point, why not do it from the beginning?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]