[Patch, fortran] PR37159

Tobias Burnus burnus@net-b.de
Fri Oct 31 02:10:00 GMT 2008


Hi Dennis,

I looked again at the patch, some remarks:

a) You put only in a check for PUT, I think one should also put in a check for GET;
the run-time library prints:
  Fortran runtime error: Array size of GET is too small.


b) Regarding the kiss_size, you have:

+      if (gfc_array_size (put, &put_size) == SUCCESS
+	  && mpz_get_ui (put_size) < kiss_size)

Question: Should one rather use
  "< kiss_size*4/put->ts.kind"
or
  "< kiss_size*4*8/(gfc_character_kinds[
           gfc_validate_kind (BT_INTEGER, put->ts.kind, false);
                                         ].bit_size)"
(The latter should be differently formatted, e.g with an auxilary
variable or two. I'm wondering whether one should use
+  kiss_size = have_gfc_real_16 ? 48 : 32;
as this removes the magic "4" in the "if" clause above; on the
other hand, if one counts
 #define KISS_DEFAULT_SEED_1 123456789, 362436069, 521288629, 316191069
 #define KISS_DEFAULT_SEED_2 987654321, 458629013, 582859209, 438195021
one counts eight 4-byte numbers ...)

The reason is that in the library one finds:

| random_seed_i4 (GFC_INTEGER_4 *size, gfc_array_i4 *put, gfc_array_i4 *get)
[...]
|      if (((put->dim[0].ubound + 1 - put->dim[0].lbound)) < kiss_size)
|        runtime_error ("Array size of PUT is too small.");

and then

| random_seed_i8 (GFC_INTEGER_8 *size, gfc_array_i8 *put, gfc_array_i8 *get)
[...]
|       if (((put->dim[0].ubound + 1 - put->dim[0].lbound)) < kiss_size / 2)
See end of the line -->-----------------------------------------------^^^^^^
|         runtime_error ("Array size of PUT is too small.");

Note: random_seed_i8 is only be used for -fdefault-integer-8; Fortran 2008
would also allow using "integer(8)" but the front-end does not allow this
- it only allows "default integers".

Tobias



More information about the Fortran mailing list