This is the mail archive of the
mailing list for the GCC project.
[Patch,Fortran,committed] PR40472/50520 - Fix SPREAD for scalar SOURCE=
- From: Tobias Burnus <burnus at net-b dot de>
- To: gcc-patches at gcc dot gnu dot org, fortran at gcc dot gnu dot org
- Date: Mon, 22 Jun 2009 22:29:44 +0200
- Subject: [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 <email@example.com>
* simplify.c (gfc_simplify_spread): Fix the case that source=
is a scalar.
--- 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
- 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.");
+ mpz_init_set_ui (size, 1);
if (mpz_get_si (size)*ncopies > gfc_option.flag_max_array_constructor)