From 48d526613961f410a87855ba2fef8909e925d9fa Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Tue, 26 May 2020 21:19:19 +0200 Subject: [PATCH] PR fortran/95089 - ICE in gfc_get_derived_type, at fortran/trans-types.c:2843 For long module name, derive type and component name, the generated name-mangled symbol did not fit into a buffer when coarrays were enabled. Provide sufficiently large temporary. 2020-05-26 Harald Anlauf gcc/fortran/ PR fortran/95089 * trans-types.c (gfc_get_derived_type): Enlarge temporary to hold mangled name "_caf_symbol". gcc/testsuite/ PR fortran/95089 * gfortran.dg/pr95089.f90: New test. --- gcc/fortran/trans-types.c | 5 +++-- gcc/testsuite/gfortran.dg/pr95089.f90 | 11 +++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/pr95089.f90 diff --git a/gcc/fortran/trans-types.c b/gcc/fortran/trans-types.c index b7712dc74d1..99844812505 100644 --- a/gcc/fortran/trans-types.c +++ b/gcc/fortran/trans-types.c @@ -2836,9 +2836,10 @@ copy_derived_types: && (c->attr.allocatable || c->attr.pointer) && !derived->attr.is_class) { - char caf_name[GFC_MAX_SYMBOL_LEN]; + /* Provide sufficient space to hold "_caf_symbol". */ + char caf_name[GFC_MAX_SYMBOL_LEN + 6]; gfc_component *token; - snprintf (caf_name, GFC_MAX_SYMBOL_LEN, "_caf_%s", c->name); + snprintf (caf_name, sizeof (caf_name), "_caf_%s", c->name); token = gfc_find_component (derived, caf_name, true, true, NULL); gcc_assert (token); c->caf_token = token->backend_decl; diff --git a/gcc/testsuite/gfortran.dg/pr95089.f90 b/gcc/testsuite/gfortran.dg/pr95089.f90 new file mode 100644 index 00000000000..1cd20f0ccc5 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr95089.f90 @@ -0,0 +1,11 @@ +! { dg-do compile } +! { dg-options "-fcoarray=lib" } +! +! PR fortran/95089 - ICE in gfc_get_derived_type, at fortran/trans-types.c:2843 + +module m23456789012345678901234567890123456789012345678901234567890123 + type t23456789012345678901234567890123456789012345678901234567890123 + type (t23456789012345678901234567890123456789012345678901234567890123), & + pointer :: z23456789012345678901234567890123456789012345678901234567890123 + end type t23456789012345678901234567890123456789012345678901234567890123 +end -- 2.30.2