From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C02323857C78; Sat, 14 Aug 2021 00:59:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C02323857C78 From: "kargl at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/101871] Array of strings of different length passed as an argument produces invalid result. Date: Sat, 14 Aug 2021 00:59:46 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 10.3.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: kargl at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Aug 2021 00:59:46 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D101871 --- 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 =3D 'H' abc =3D [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 =3D 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 =3D {expr_type =3D EXPR_ARRAY, ts =3D {type =3D BT_CHARACTER, kind =3D = 1, u =3D { derived =3D 0x803422870, cl =3D 0x803422870, pad =3D 54667376}, inter= face =3D 0x0,=20 is_c_interop =3D 0, is_iso_c =3D 0, f90_type =3D BT_UNKNOWN, deferred = =3D false,=20 interop_kind =3D 0x7fffffffd950}, rank =3D 1, shape =3D 0x0, symtree = =3D 0x0, ref =3D 0x0, where =3D { nextc =3D 0x803431c2c, lb =3D 0x803431be0}, base_expr =3D 0x0, is_snan = =3D 0, error =3D 0,=20 user_operator =3D 0, mold =3D 0, must_finalize =3D 0, no_bounds_check =3D= 0, external_blas =3D 0,=20 do_not_resolve_again =3D 0, do_not_warn =3D 0, from_constructor =3D 0, representation =3D { length =3D 0, string =3D 0x0}, boz =3D {len =3D 0, rdx =3D 0, str =3D 0= x0}, value =3D { logical =3D 54623680, iokind =3D 54623680, integer =3D {{_mp_alloc =3D = 54623680, _mp_size =3D 8,=20 _mp_d =3D 0x0}}, real =3D {{_mpfr_prec =3D 34414362048, _mpfr_sign = =3D 0, _mpfr_exp =3D 0,=20 _mpfr_d =3D 0x0}}, complex =3D {{re =3D {{_mpfr_prec =3D 3441436204= 8, _mpfr_sign =3D 0,=20 _mpfr_exp =3D 0, _mpfr_d =3D 0x0}}, im =3D {{_mpfr_prec =3D 0, = _mpfr_sign =3D 0,=20 _mpfr_exp =3D 0, _mpfr_d =3D 0x0}}}}, op =3D {op =3D 54623680, = uop =3D 0x0, op1 =3D 0x0,=20 op2 =3D 0x0}, function =3D {actual =3D 0x803417dc0, name =3D 0x0, isy= m =3D 0x0, esym =3D 0x0},=20 compcall =3D {actual =3D 0x803417dc0, name =3D 0x0, base_object =3D 0x0= , tbp =3D 0x0,=20 ignore_pass =3D 0, assign =3D 0}, character =3D {length =3D 344143620= 48, string =3D 0x0},=20 constructor =3D 0x803417dc0}, param_list =3D 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.=