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

--- Comment #4 from kargl at gcc dot gnu.org ---
With this testcase,

program tao_program

   implicit none

   integer i
   character(80) abc(9)
   character(1) n

   n = 'H'
   abc = [character(80) :: &
   &  'a'//n, 'ab', 'abc', 'd', 'def', 'g', 'ghi', 'z', 'zyxwvut']

   call io([character(80) :: &
   &  'a'//n, 'ab', 'abc', 'd', 'def', 'g', 'ghi', 'z', 'zyxwvut'])

   contains

      subroutine io (lines)
         character(*) lines(:)
         integer i
         do i = 1, size(lines)
            write(*,'(I0,A)') i, ' ' // trim(abc(i)) // ' ' // trim(lines(i))
         end do
      end subroutine io

end program

I find that the actual argument is correctly parsed.

(gdb) p *tail->expr
$12 = {expr_type = EXPR_ARRAY, ts = {type = BT_CHARACTER, kind = 1, u = {
      derived = 0x803422870, cl = 0x803422870, pad = 54667376}, interface =
0x0, 
    is_c_interop = 0, is_iso_c = 0, f90_type = BT_UNKNOWN, deferred = false, 
    interop_kind = 0x7fffffffd950}, rank = 1, shape = 0x0, symtree = 0x0, ref =
0x0, where = {
    nextc = 0x803431c2c, lb = 0x803431be0}, base_expr = 0x0, is_snan = 0, error
= 0, 
  user_operator = 0, mold = 0, must_finalize = 0, no_bounds_check = 0,
external_blas = 0, 
  do_not_resolve_again = 0, do_not_warn = 0, from_constructor = 0,
representation = {
    length = 0, string = 0x0}, boz = {len = 0, rdx = 0, str = 0x0}, value = {
    logical = 54623680, iokind = 54623680, integer = {{_mp_alloc = 54623680,
_mp_size = 8, 
        _mp_d = 0x0}}, real = {{_mpfr_prec = 34414362048, _mpfr_sign = 0,
_mpfr_exp = 0, 
        _mpfr_d = 0x0}}, complex = {{re = {{_mpfr_prec = 34414362048,
_mpfr_sign = 0, 
            _mpfr_exp = 0, _mpfr_d = 0x0}}, im = {{_mpfr_prec = 0, _mpfr_sign =
0, 
            _mpfr_exp = 0, _mpfr_d = 0x0}}}}, op = {op = 54623680, uop = 0x0,
op1 = 0x0, 
      op2 = 0x0}, function = {actual = 0x803417dc0, name = 0x0, isym = 0x0,
esym = 0x0}, 
    compcall = {actual = 0x803417dc0, name = 0x0, base_object = 0x0, tbp = 0x0, 
      ignore_pass = 0, assign = 0}, character = {length = 34414362048, string =
0x0}, 
    constructor = 0x803417dc0}, param_list = 0x0}
(gdb) call debug(tail->expr)
(/ (// 'a' tao_program:n) , 'ab' , 'abc' , 'd' , 'def' , 'g' , 'ghi' , 'z' ,
'zyxwvut' /) (CHARACTER 80 1)
(gdb) call debug(tail->expr->ts)
(CHARACTER 80 1)

Both the elements and the typespec are set correctly.  So, when the
actual argument is evaluate the first element is (// 'a' tao_program:n)
which will have length of 2.  This is then used for all other elements.
Whoops.

Reply via email to