From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 593ED3858D32; Fri, 29 Mar 2024 16:37:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 593ED3858D32 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1711730234; bh=NTrQk1FaTNhcSsWODQH9S0XqhzEc8FNCQyLf6vqr1pg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=TeQ4tZD+Ew4nSytlKkQzt3yZ9o7Cnay6/+HECRITY1kPnEzufj8h/XCD41/5D4isI 3Wl2hyYvkGV7AVDyWoCPZbFOd6o2SYvKfX3bOFhioXG/oxLrrsRJe7BuzbDjoImgFf B4NwsfOvNCOUtek2iufmRgywnK4YjQ1SP4Jru5hI= From: "anlauf at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/113956] [13/14 Regression] ice in gfc_trans_pointer_assignment, at fortran/trans-expr.cc:10524 Date: Fri, 29 Mar 2024 16:37:13 +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: 14.0 X-Bugzilla-Keywords: ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: anlauf 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: 13.3 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=3D113956 --- Comment #4 from anlauf at gcc dot gnu.org --- (In reply to Paul Thomas from comment #3) > I can see why the assert is there but it is manifestly wrong for both the > assumed length target and a constant length. That's why I wanted to pass this on to you. I am not sure what the precise logic should be. > I was thrown a bit by the > distros nulling out the asserts so that it compiled just fine with the > system gfortran. If the system gfortran is based on 13.2 *release* then the bug is not yet there ;-) It entered 13-branch through backport r13-7986. > Your patch is perfect :- This compiles and runs correctly: > module m > contains > subroutine test_array_char(p, x) > character(*), target :: x(:) > character(:), pointer :: p(:) > p =3D> x > end subroutine > end module >=20 > use m > character(:), allocatable, target :: chr(:) > character(:), pointer :: p(:) > chr =3D ["ab","cd"] > call test_array_char (p, chr) > print '(l2,i4,2a4)', loc(chr) =3D=3D loc(p), len(p), p > end The original testcase attached here has a second subroutine that ICEd: subroutine test_array_char_remap(p, x) character(*), target :: x(100) character(:), pointer :: p(:, :) p(2:11, 3:12) =3D> x end subroutine It is also fixed by the patch, and checking the bounds etc. in the caller shows that it works correct too :-) program main implicit none character(3) :: x(100) =3D "* #" character(:), pointer :: p(:), q(:,:) call test_array_char (p, x) print *, associated (p) print *, size (p) print *, len (p) print *, p(5)(1:1) call test_array_char_remap (q, x) print *, associated (q) print *, size (q) print *, len (q) print *, lbound(q), ubound(q) print *, q(5,5)(3:3) contains subroutine test_array_char(p, x) character(*), target :: x(100) character(:), pointer :: p(:) p =3D> x end subroutine subroutine test_array_char_remap(p, x) character(*), target :: x(100) character(:), pointer :: p(:, :) p(2:11, 3:12) =3D> x end subroutine end=