From 470ebd31843db58fc503ccef38b82d0da93c65e4 Mon Sep 17 00:00:00 2001 From: Paul Thomas Date: Sun, 24 Nov 2024 12:01:32 +0000 Subject: Fortran: Fix segfault in allocation of unlimited poly array [PR85869] 2024-11-24 Paul Thomas gcc/fortran/ChangeLog PR fortran/85869 * trans-expr.cc (trans_class_vptr_len_assignment): To access the '_len' field, re must be unlimited polymorphic. gcc/testsuite/ PR fortran/85869 * gfortran.dg/pr85869.f90: Comment out test of component refs. --- gcc/fortran/trans-expr.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'gcc/fortran/trans-expr.cc') diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc index 7013dd3..bc1d5a8 100644 --- a/gcc/fortran/trans-expr.cc +++ b/gcc/fortran/trans-expr.cc @@ -21,6 +21,7 @@ along with GCC; see the file COPYING3. If not see /* trans-expr.cc-- generate GENERIC trees for gfc_expr. */ +#define INCLUDE_MEMORY #include "config.h" #include "system.h" #include "coretypes.h" @@ -10421,7 +10422,7 @@ trans_class_vptr_len_assignment (stmtblock_t *block, gfc_expr * le, vptr_expr = NULL; se.expr = gfc_class_vptr_get (GFC_DECL_SAVED_DESCRIPTOR ( re->symtree->n.sym->backend_decl)); - if (to_len) + if (to_len && UNLIMITED_POLY (re)) from_len = gfc_class_len_get (GFC_DECL_SAVED_DESCRIPTOR ( re->symtree->n.sym->backend_decl)); } -- cgit v1.1