Hi Harald,

That's interesting - the string length '.q' is not set for either of the
associate blocks. I'm onto it.

Thanks

Paul


On Wed, 12 Apr 2023 at 20:26, Harald Anlauf <anl...@gmx.de> wrote:

> Hi Paul,
>
> On 4/12/23 17:25, Paul Richard Thomas via Gcc-patches wrote:
> > Hi All,
> >
> > I think that the changelog says it all. OK for mainline?
>
> this looks almost fine, but still fails if one directly uses the
> dummy argument as the ASSOCIATE target, as in:
>
> program p
>    implicit none
>    character(4) :: c(2) = ["abcd","efgh"]
>    call dcs0 (c)
> ! call dcs0 (["abcd","efgh"])
> contains
>    subroutine dcs0(a)
>      character(len=*), intent(in) :: a(:)
>      print *, size(a),len(a)
>      associate (q => a(:))
>        print *, size(q),len(q)
>      end associate
>      associate (q => a(:)(:))
>        print *, size(q),len(q)
>      end associate
>      return
>    end subroutine dcs0
> end
>
> This prints e.g.
>
>             2           4
>             2           0
>             2           0
>
> (sometimes I also get junk values for the character length).
>
> Can you please have another look?
>
> Thanks,
> Harald
>
>
> > Paul
> >
> > Fortran: Fix some deferred character problems in associate [PR109451]
> >
> > 2023-04-07  Paul Thomas  <pa...@gcc.gnu.org>
> >
> > gcc/fortran
> > PR fortran/109451
> > * trans-array.cc (gfc_conv_expr_descriptor): Guard expression
> > character length backend decl before using it. Suppress the
> > assignment if lhs equals rhs.
> > * trans-io.cc (gfc_trans_transfer): Scalarize transfer of
> > associate variables pointing to a variable. Add comment.
> >
> >
> > gcc/testsuite/
> > PR fortran/109451
> > * gfortran.dg/associate_61.f90 : New test
>
>

-- 
"If you can't explain it simply, you don't understand it well enough" -
Albert Einstein

Reply via email to