https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113956
--- 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 => x > end subroutine > end module > > use m > character(:), allocatable, target :: chr(:) > character(:), pointer :: p(:) > chr = ["ab","cd"] > call test_array_char (p, chr) > print '(l2,i4,2a4)', loc(chr) == 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) => 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) = "* #" 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 => x end subroutine subroutine test_array_char_remap(p, x) character(*), target :: x(100) character(:), pointer :: p(:, :) p(2:11, 3:12) => x end subroutine end