From c02ce61cf7848d32600ed1bc1c2c6eb24fb3bf11 Mon Sep 17 00:00:00 2001 From: fxcoudert Date: Wed, 15 Aug 2007 12:35:57 +0000 Subject: [PATCH] PR fortran/33077 * intrinsics/random.c (random_seed_i8): Fix code logic. * gfortran.dg/random_7.f90: Initialize variable. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@127512 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/random_7.f90 | 3 +++ libgfortran/ChangeLog | 5 +++++ libgfortran/intrinsics/random.c | 8 ++++---- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 86abadd..bde9f73 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2007-08-15 Francois-Xavier Coudert + + PR fortran/33077 + * gfortran.dg/random_7.f90: Initialize variable. + 2007-08-15 Jakub Jelinek PR middle-end/33074 diff --git a/gcc/testsuite/gfortran.dg/random_7.f90 b/gcc/testsuite/gfortran.dg/random_7.f90 index 46d8ccb..6435a34 100644 --- a/gcc/testsuite/gfortran.dg/random_7.f90 +++ b/gcc/testsuite/gfortran.dg/random_7.f90 @@ -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) diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index a74bd44..2305b3e 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,8 @@ +2007-08-15 Francois-Xavier Coudert + + PR fortran/33077 + * intrinsics/random.c (random_seed_i8): Fix code logic. + 2007-08-13 Danny Smith * acinclude.m4 (GTHREAD_USE_WEAK) Define to 0 for mingw32. diff --git a/libgfortran/intrinsics/random.c b/libgfortran/intrinsics/random.c index f64f21c..00029c5 100644 --- a/libgfortran/intrinsics/random.c +++ b/libgfortran/intrinsics/random.c @@ -731,8 +731,8 @@ random_seed_i8 (GFC_INTEGER_8 *size, gfc_array_i8 *put, gfc_array_i8 *get) 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_array_i8 *put, gfc_array_i8 *get) 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)); } -- 2.7.4