From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id CD2893858D38; Sun, 28 May 2023 18:52:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CD2893858D38 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685299922; bh=D0+TnnWLTC6wk77U5xfHDqZy44OHxMpxwAjbhT/31YE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=XGYdTi9zc2zAVvcgnATd8Ndbhx9zpDJA3KXMDwD+Yqm2e6axEdz3ckbsLRor5HruG lpKboshwl+8B8G9Tq867AlEcx5xCksJTHzX8i1hzR2DoGBQCgNUkwmI2G3tWHdZQFJ jFG8h33ZGnLJx16Nhl1x0+w5pwr8cFlP3JKGtYnw= From: "kargl at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/88486] ICE in gfc_conv_scalarized_array_ref, at fortran/trans-array.c:3401 Date: Sun, 28 May 2023 18:52:02 +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: 9.0 X-Bugzilla-Keywords: ice-on-valid-code 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D88486 --- Comment #5 from kargl at gcc dot gnu.org --- (In reply to G. Steinmetz from comment #0) > Affects versions down to at least gfortran-5. > Under the hood related to pr85686. >=20 >=20 > $ cat z1.f90 > subroutine s(x) > character(:), allocatable :: x(:) > x =3D ['bcd'] > x =3D ['a'//x//'e'] > print *, x > end >=20 This compiles with GNU Fortran (GCC) 13.0.1 20230408 (experimental). This has an ICE with GNU Fortran (FreeBSD Ports Collection) 12.2.0. Filling out the code to something that actually does something reveals a wrong-code issue with an array constructor. There are a boat load of warnings of uninitialized variables, e.g.,=20 a.f90:53:34: 53 | x =3D [ ('a' // x // 'e') ] | ^ Warning: '__var_1_realloc_string.dim[0].ubound' is used uninitialized [-Wuninitialized] a.f90:1:11: 1 | program foo | ^ note: '__var_1_realloc_string' declared here a.f90:3:36: 3 | character(:), allocatable :: a(:) | ^ Warning: '.a' is used uninitialized [-Wuninitialized] a.f90:34:22: 34 | end subroutine s | ^ note: '.a' declared here program foo character(:), allocatable :: a(:) call s(a) print '(A,1X,2(I0,1X),/)', 'a: >>' // a // '<<', size(a), len(a(1)) if (allocated(a)) deallocate(a) call t(a) print '(A,1X,2(I0,1X),/)', 'a: >>' // a // '<<', size(a), len(a(1)) if (allocated(a)) deallocate(a) call u(a) print '(A,1X,2(I0,1X),/)', 'a: >>' // a // '<<', size(a), len(a(1)) if (allocated(a)) deallocate(a) call v(a) print '(A,1X,2(I0,1X),/)', 'a: >>' // a // '<<', size(a), len(a(1)) if (allocated(a)) deallocate(a) call w(a) print '(A,1X,2(I0,1X),/)', 'a: >>' // a // '<<', size(a), len(a(1)) if (allocated(a)) deallocate(a) contains subroutine s(x) character(:), allocatable :: x(:) x =3D ['bcd'] x =3D ['a' // x // 'e'] print '(A,1X,2(I0,1X))', 's: >>' // x // '<<', size(x), len(x(1)) end subroutine s subroutine t(x) character(:), allocatable :: x(:) x =3D ['bcd'] x =3D 'a' // x // 'e' print '(A,1X,2(I0,1X))', 't: >>' // x // '<<', size(x), len(x(1)) end subroutine t subroutine u(x) character(:), allocatable :: x(:) x =3D ['bcd'] x =3D [ ('a' // x // 'e') ] print '(A,1X,2(I0,1X))', 'u: >>' // x // '<<', size(x), len(x(1)) end subroutine u subroutine v(x) character(:), allocatable, intent(out) :: x(:) x =3D ['bcd'] x =3D [ ('a' // x // 'e') ] print '(A,1X,2(I0,1X))', 'v: >>' // x // '<<', size(x), len(x(1)) end subroutine v subroutine w(x) character(:), allocatable, intent(out) :: x(:) x =3D [ 'a' // ['bcd'] // 'e' ] print '(A,1X,2(I0,1X))', 'w: >>' // x // '<<', size(x), len(x(1)) end subroutine w end program foo s: >>abcde<< 1 5 a: >>abc<< 1 3 <--- whoops t: >>abcde<< 1 5 a: >>abcde<< 1 5 u: >>abcde<< 1 5 a: >>abc<< 1 3 <--- whoops v: >>abcde<< 1 5 a: >>abc<< 1 3 <--- whoops w: >>abcde<< 1 5 a: >>abcde<< 1 5=