[patch, fortran] PR37159 - add size check for random_seed(get)

Tobias Burnus burnus@net-b.de
Wed Dec 10 11:07:00 GMT 2008


Daniel Franke wrote:
> The RANDOM_SEED intrinsic lacked a check for the GET argument (PUT was already 
> in place). This patch adds the missing check and also takes care if the 
> default integer size is 4 or 8.
>
> The latter is implemented as:
>   kiss_size = (have_gfc_real_16 ? 48 : 32) / gfc_default_integer_kind;
> Is it acceptable to use gfc_default_integer_kind in this way?
>   
I think it should be OK. Even when we add new integer kinds (e.g. for
decimal calculations, but that probably rather affects REAL kinds), this
number will almost certainly remain the same.

Why are you changing the error message:

-	gfc_error ("Array PUT of intrinsic %s is too small (%i/%i) at %L", 
-		   gfc_current_intrinsic, (int) mpz_get_ui (put_size),
-		   kiss_size, where);
+	gfc_error ("Size of '%s' argument of '%s' intrinsic at %L "
+		   "too small (%i/%i)",
+		   gfc_current_intrinsic_arg[1], gfc_current_intrinsic, where, 
+		   (int) mpz_get_ui (put_size), kiss_size);


Reading the source it is much easier to have "PUT" than %s ....
gfc_current_intrinsic_arg[1]. For the translation it probably does not
matter that much, but for choosing the right article having there an
actual word rather than %s might be an advantage for the translator. (On
the other hand, %s means reduces the number of strings to be translated
by one).

Thus, if there is a compelling reason, leave it as is, but otherwise I
prefer PUT and GET to %s and especially to "gfc_current_intrinsic_arg[1]".

> Bootstrapped and regression tested on i686-pc-linux-gnu.
> Ok for trunk/4.5?
>   
OK.

Tobias


> 2008-12-10  Daniel Franke  <franke.daniel@gmail.com>
>
> 	PR fortran/37159
> 	* check.c (gfc_check_random_seed): Added size check for GET dummy
> 	argument, reworded error messages to follow common pattern.
>
> 2008-12-10  Daniel Franke  <franke.daniel@gmail.com>
>
> 	PR fortran/37159
> 	* gfortran.dg/random_seed_1.f90: Updated.



More information about the Gcc-patches mailing list