This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch,Fortran,committed] PR40472/50520 - Fix SPREAD for scalar SOURCE=

Attached patch was committed as Rev. 148814 after approval
by Paul in the PR.

The problem was that gfc_array_size does not return any size if
SOURCE is a scalar (the mpz_t is not initialized), which then
causes problems for "mpz_get_si (size)*ncopies". The solution is
simple: One has first to check whether SOURCE= is an array.

Committed after bootstrapping, check-gfortran + check libgomp.
I also valgrind-checked the test case in the PR. (For some
reason it does not fail on my x86-64-linux system.)
The fix was also confirmed by Dominique on PPC Darwin (?).

2009-06-22  Tobias Burnus  <>

	PR fortran/40472
	PR fortran/50520
	* simplify.c (gfc_simplify_spread): Fix the case that source=
	is a scalar.

Index: gcc/fortran/simplify.c
--- gcc/fortran/simplify.c	(Revision 148809)
+++ gcc/fortran/simplify.c	(Arbeitskopie)
@@ -5117,7 +5117,14 @@ gfc_simplify_spread (gfc_expr *source, g
   /* Do not allow the array size to exceed the limit for an array
      constructor.  */
-  gfc_array_size (source, &size);
+  if (source->expr_type == EXPR_ARRAY)
+    {
+      if (gfc_array_size (source, &size) == FAILURE)
+	gfc_internal_error ("Failure getting length of a constant array.");
+    }
+  else
+    mpz_init_set_ui (size, 1);
   if (mpz_get_si (size)*ncopies > gfc_option.flag_max_array_constructor)
     return NULL;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]