https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88486
--- Comment #8 from Steve Kargl <kargl at gcc dot gnu.org> ---
(In reply to Jerry DeLisle from comment #7)
> The original test case does not ICE any more.
>
> subroutine s(x)
> character(:), allocatable :: x(:)
> x = ['bcd']
> x = ['a'//x//'e']
> print *, x
> end
>
> $ gfc -c foo.f90
> $
>
> The -fdump-tree-original is full of nonsense. Please enlighten me.
The len from the expression within the array constructor is not
being used to update the len of x in the lhs. Consider
program foo
character(:), allocatable :: a(:)
call s(a)
print '(2A,2I2)', a, size(a), len(a)
contains
subroutine s(x)
character(:), allocatable :: x(:)
x = ['xxxx','yyyy']
print '(2A,2I2)', x, len(x(1)), len(x(2))
x = ['^' // x // '^']
end subroutine s
end program foo
% flang21 -o z -std=f2018 kk.f90 && ./z
xxxxyyyy 4 4
^xxxx^^yyyy^ 2 6
% gfcx -o z -Wall kk.f90 && ./z
xxxxyyyy 4 4
^xxx^yyy 2 4
So, in the second line we get ^xxx from the first
element a(1) and ^yyy from a(2).
The first assignment "x = ['xxxx','yyyy']" does the correct
allocation of a rank 1 array with 2 elements with length of
4. The re-allocation of the lhs "x = ['^' // x // '^']" is
updating the length. Note, trying to force an evaluation with
parentheses "x = [('^' // x // '^')]" does not work.
Finally, if one has "x = ['^' // ['xxxx','yyyy'] // '^']" one
gets the expected answer because gfortran constant folds the
constant expression.
No. I don't have any idea where to look to fix the issue, yet.