]> gcc.gnu.org Git - gcc.git/commitdiff
PR fortran/95827 - Buffer overflows with submodules and coarrays
authorHarald Anlauf <anlauf@gmx.de>
Wed, 24 Jun 2020 19:03:47 +0000 (21:03 +0200)
committerHarald Anlauf <anlauf@gmx.de>
Wed, 24 Jun 2020 19:03:47 +0000 (21:03 +0200)
With submodules and coarrays, name mangling results in long internal
symbols.  Enlarge internal buffer.

gcc/fortran/
PR fortran/95827
* iresolve.c (gfc_get_string): Enlarge internal buffer used in
generating the mangled name.

gcc/fortran/iresolve.c
gcc/testsuite/gfortran.dg/pr95827.f90 [new file with mode: 0644]

index aa9bb328a0f32f48e9e99cc0687d0ea73df5f2e9..73769615c20c1ff93572cb2497f2ae35c5e84271 100644 (file)
@@ -47,8 +47,8 @@ along with GCC; see the file COPYING3.  If not see
 const char *
 gfc_get_string (const char *format, ...)
 {
-  /* Provide sufficient space to hold "_F.symbol.symbol_MOD_symbol".  */
-  char temp_name[4 + 2*GFC_MAX_SYMBOL_LEN + 5 + GFC_MAX_SYMBOL_LEN + 1];
+  /* Provide sufficient space for "_F.caf_token__symbol.symbol_MOD_symbol".  */
+  char temp_name[15 + 2*GFC_MAX_SYMBOL_LEN + 5 + GFC_MAX_SYMBOL_LEN + 1];
   const char *str;
   va_list ap;
   tree ident;
diff --git a/gcc/testsuite/gfortran.dg/pr95827.f90 b/gcc/testsuite/gfortran.dg/pr95827.f90
new file mode 100644 (file)
index 0000000..545e344
--- /dev/null
@@ -0,0 +1,14 @@
+! { dg-do compile }
+! { dg-options "-fcoarray=lib -fsecond-underscore" }
+! PR fortran/95827 - ICE in gfc_get_string, at fortran/iresolve.c:70
+
+module m2345678901234567890123456789012345678901234567890123456789_123
+  interface
+     module subroutine s2345678901234567890123456789012345678901234567890123456789_123
+     end
+   end interface
+end
+submodule(m2345678901234567890123456789012345678901234567890123456789_123) &
+          n2345678901234567890123456789012345678901234567890123456789_123
+  integer :: x2345678901234567890123456789012345678901234567890123456789_123[*]
+end
This page took 0.068754 seconds and 5 git commands to generate.