Hi Paul,

On 4/2/26 11:36, Paul Richard Thomas wrote:
Hi All,

The attached fixes the PR and cures the memory leak in pr105168.

Regtested on FC43/x86_64. OK for mainline and later backporting?

as you say, the patch is indeed not too pretty, although
it works with the testcase that comes with it.

It does not fix the following variation for me:

program p
  type :: t
  end type
contains
  recursive function f(x) result(z)
    class(*), intent(in) :: x(:)
    type(t)  :: z (size(x))
    class(t), allocatable :: a(:)
    class(t), allocatable :: b(:)
    allocate (a(size(x)))
    b = f((a))
    z = b   ! no ICE
    z = (b) ! ICE
  end
end

% gfc-16 pr100155.f90
f951: internal compiler error: Segmentation fault
0x26ba694 internal_error(char const*, ...)
        ../../gcc-trunk/gcc/diagnostic-global-context.cc:787
0x127c0af crash_signal
        ../../gcc-trunk/gcc/toplev.cc:325
0xa2bc63 gfc_add_component_ref(gfc_expr*, char const*)
        ../../gcc-trunk/gcc/fortran/class.cc:217
0xaf6642 resolve_ordinary_assign
        ../../gcc-trunk/gcc/fortran/resolve.cc:13223
0xaf6642 gfc_resolve_code(gfc_code*, gfc_namespace*)
        ../../gcc-trunk/gcc/fortran/resolve.cc:14336
0xaf7c62 resolve_codes
        ../../gcc-trunk/gcc/fortran/resolve.cc:20289
0xaf7ba3 resolve_codes
        ../../gcc-trunk/gcc/fortran/resolve.cc:20270
0xaf7d02 gfc_resolve(gfc_namespace*)
        ../../gcc-trunk/gcc/fortran/resolve.cc:20324
0xae2ac9 resolve_all_program_units
        ../../gcc-trunk/gcc/fortran/parse.cc:7531
0xae2ac9 gfc_parse_file()
        ../../gcc-trunk/gcc/fortran/parse.cc:7793
0xb41caf gfc_be_parse_file
        ../../gcc-trunk/gcc/fortran/f95-lang.cc:247

You might proceed nevertheless for 16-trunk, and either keep
an eye on the above, or add it to the present (or a new) PR.
(It could be a different existing PR; haven't searched bugzilla.
In that case just go ahead.)

Thanks,
Harald


Reply via email to