https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113956
--- Comment #3 from Paul Thomas <pault at gcc dot gnu.org> --- (In reply to anlauf from comment #2) > Reduced testcase: > > subroutine test_array_char(p, x) > character(*), target :: x(100) > character(:), pointer :: p(:) > p => x > end subroutine > > > We hit an assert that can be worked around with the following patch: > > diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc > index d21e3956d6e..fa31f950363 100644 > --- a/gcc/fortran/trans-expr.cc > +++ b/gcc/fortran/trans-expr.cc > @@ -10534,12 +10535,9 @@ gfc_trans_pointer_assignment (gfc_expr * expr1, > gfc_expr * expr2) > { > gfc_symbol *psym = expr1->symtree->n.sym; > tmp = NULL_TREE; > - if (psym->ts.type == BT_CHARACTER) > - { > - gcc_assert (psym->ts.u.cl->backend_decl > - && VAR_P (psym->ts.u.cl->backend_decl)); > - tmp = psym->ts.u.cl->backend_decl; > - } > + if (psym->ts.type == BT_CHARACTER > + && psym->ts.u.cl->backend_decl) > + tmp = psym->ts.u.cl->backend_decl; > else if (expr1->ts.u.cl->backend_decl > && VAR_P (expr1->ts.u.cl->backend_decl)) > tmp = expr1->ts.u.cl->backend_decl; > > > This fragment was touched by Paul's fix for pr67740 (r14-4583), so adding > him. > > @Paul: can you please have a look? I can see why the assert is there but it is manifestly wrong for both the assumed length target and a constant length. I was thrown a bit by the distros nulling out the asserts so that it compiled just fine with the system gfortran. 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 Cheers Paul