Hello Jerry,

>From an admittedly very brief perusal, the patch looks good to me.

I trust that you did the regtestsing?

Paul

On Sat, 26 Sept 2026 at 02:46, Jerry DeLisle <[email protected]> wrote:
>
> See attached patch. This fixes an ICE with %LEN of a deferred-length
> character variable in ASSOCIATE.
>
> Regression tested on x86_64.
>
> OK for mainline?
>
> Regards,
>
> Jerry
>
> ---
>
> fortran: [PR127187] ICE with %LEN of deferred-length character in ASSOCIATE
>
> A %LEN or %KIND inquiry of a deferred-length character variable gives
> an INTEGER expression that still carried the deferred flag of the
> character typespec.  An associate-name with such a selector inherited
> it, and gfc_get_symbol_decl then segfaulted looking for its string
> length.
>
> A related bug: for an associate-name whose selector is deferred-length
> character, resolve_variable reset the typespec of the expression to
> that of the associate-name unless a substring reference was present.
> An inquiry reference of the associate-name, e.g. q%len, thus reverted
> to CHARACTER, giving an ICE in conv_inquiry or a spurious error on
> comparison with an INTEGER.
>
>         PR fortran/127187
>
> gcc/fortran/ChangeLog:
>
>         PR fortran/127187
>         * primary.cc (gfc_match_varspec): Clear the deferred flag, and
>         for KIND the charlen, of the INTEGER result of a LEN or KIND
>         inquiry.
>         * resolve.cc (resolve_variable): Do not reset the typespec of a
>         deferred-length character associate-name expression that has an
>         inquiry reference.
>
> gcc/testsuite/ChangeLog:
>
>         PR fortran/127187
>         * gfortran.dg/associate_90.f90: New test.

Reply via email to