This is the mail archive of the gcc-patches@gcc.gnu.org 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]

[gfortran,committed] RANDOM_SEED with -fdefault-integer-8


Attached patch committed as rev. 127512 to fix my previous patch for
RANDOM_SEED.

Sorry for the breakage, again.
FX



Index: libgfortran/intrinsics/random.c
===================================================================
--- libgfortran/intrinsics/random.c     (revision 127490)
+++ libgfortran/intrinsics/random.c     (working copy)
@@ -731,8 +731,8 @@ random_seed_i8 (GFC_INTEGER_8 *size, gfc
         runtime_error ("Array size of PUT is too small.");

       /*  This code now should do correct strides.  */
-      for (i = 0; i < kiss_size; i += 2)
-       memcpy (&kiss_seed[i], &(put->data[i * put->dim[0].stride]),
+      for (i = 0; i < kiss_size / 2; i++)
+       memcpy (&kiss_seed[2*i], &(put->data[i * put->dim[0].stride]),
                sizeof (GFC_UINTEGER_8));
     }

@@ -748,8 +748,8 @@ random_seed_i8 (GFC_INTEGER_8 *size, gfc
        runtime_error ("Array size of GET is too small.");

       /*  This code now should do correct strides.  */
-      for (i = 0; i < kiss_size; i += 2)
-       memcpy (&(get->data[i * get->dim[0].stride]), &kiss_seed[i],
+      for (i = 0; i < kiss_size / 2; i++)
+       memcpy (&(get->data[i * get->dim[0].stride]), &kiss_seed[2*i],
                sizeof (GFC_UINTEGER_8));
     }

Index: libgfortran/ChangeLog
===================================================================
--- libgfortran/ChangeLog       (revision 127511)
+++ libgfortran/ChangeLog       (working copy)
@@ -1,3 +1,8 @@
+2007-08-15  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>
+
+       PR fortran/33077
+       * intrinsics/random.c (random_seed_i8): Fix code logic.
+
 2007-08-13  Danny Smith  <dannysmit@users.sourceforge.net>

        * acinclude.m4 (GTHREAD_USE_WEAK) Define to 0 for mingw32.
Index: gcc/testsuite/ChangeLog
===================================================================
--- gcc/testsuite/ChangeLog     (revision 127511)
+++ gcc/testsuite/ChangeLog     (working copy)
@@ -1,3 +1,8 @@
+2007-08-15  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>
+
+       PR fortran/33077
+       * gfortran.dg/random_7.f90: Initialize variable.
+
 2007-08-15  Jakub Jelinek  <jakub@redhat.com>

        PR middle-end/33074
Index: gcc/testsuite/gfortran.dg/random_7.f90
===================================================================
--- gcc/testsuite/gfortran.dg/random_7.f90      (revision 127490)
+++ gcc/testsuite/gfortran.dg/random_7.f90      (working copy)
@@ -7,8 +7,11 @@ program trs
   integer, allocatable, dimension(:) :: seed, check
   call test_random_seed(size)
   allocate(seed(size),check(size))
+  seed(:) = huge(seed) / 17
   call test_random_seed(put=seed)
   call test_random_seed(get=check)
+  print *, seed
+  print *, check
   if (any (seed /= check)) call abort
 contains
   subroutine test_random_seed(size, put, get)


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