Another rather obvious case of a buffer too small to hold a name-mangled symbol,
this time with coarrays enabled.
OK for master?
Thanks,
Harald
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.
gcc/fortran/
2020-05-25 Harald Anlauf <[email protected]>
PR fortran/95089
* trans-types.c (gfc_get_derived_type): Enlarge temporary to hold
mangled name "_caf_symbol".
gcc/testsuite/
2020-05-25 Harald Anlauf <[email protected]>
PR fortran/95089
* gfortran.dg/pr95089.f90: New test.
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