------- Comment #10 from tkoenig at gcc dot gnu dot org 2006-05-27 19:10 ------- This bug does not occur with g77, as this version of the test program shows:
$ cat testdirect.f program testdirect implicit none integer a (100) integer i,j,k,ier real x integer myrand(100) data myrand / 13, 9, 34, 41, 25, 98, 6, 12, 11, 44, 79, 3, & 64, 61, 77, 57, 59, 2, 92, 38, 71, 64, 31, 60, 28, 90, 26, & 97, 47, 26, 48, 96, 95, 82, 100, 90, 45, 71, 71, 67, 72, & 76, 94, 49, 85, 45, 100, 22, 96, 48, 13, 23, 40, 14, 76, 99, & 96, 90, 65, 2, 8, 60, 96, 19, 45, 1, 100, 48, 91, 20, 92, & 72, 81, 59, 24, 37, 43, 21, 54, 68, 31, 19, 79, 63, 41, & 42, 12, 10, 62, 43, 9, 30, 9, 54, 35, 4, 5, 55, 3, 94 / do i=1,100 a(i) = 0 end do C call random_seed() open(unit=15,file="testdirectio",access="direct", & form="unformatted",recl=4) do i=1,100 k = myrand(i) ! k= int(x * 100)+1 a(i)=k write(unit=15, rec=k) k end do do j=1,100 read(unit=15, rec=a(j), iostat=ier) k if (ier.ne.0) then print *, "No Record: ", j else if (a(j) .ne. k) print *, "Bad Record at ",a(j), k endif enddo close(unit=15, status="delete") end $ g77 testdirect.f $ ./a.out $ gfortran testdirect.f $ ./a.out Bad Record at 13 14 Bad Record at 34 0 Bad Record at 25 26 Bad Record at 98 99 Bad Record at 6 11 Bad Record at 11 0 Bad Record at 44 45 Bad Record at 64 65 Bad Record at 61 0 Bad Record at 77 0 Bad Record at 57 59 Bad Record at 2 0 Bad Record at 38 0 Bad Record at 71 72 Bad Record at 64 65 Bad Record at 60 0 Bad Record at 28 0 Bad Record at 90 98 Bad Record at 26 34 Bad Record at 97 0 Bad Record at 47 48 Bad Record at 26 34 Bad Record at 96 97 Bad Record at 95 96 Bad Record at 82 0 Bad Record at 90 98 Bad Record at 45 0 Bad Record at 71 72 Bad Record at 71 72 Bad Record at 67 0 Bad Record at 76 0 Bad Record at 49 0 Bad Record at 85 0 Bad Record at 45 0 Bad Record at 22 23 Bad Record at 96 97 Bad Record at 13 14 Bad Record at 23 0 Bad Record at 40 0 Bad Record at 14 0 Bad Record at 76 0 Bad Record at 99 100 Bad Record at 96 97 Bad Record at 90 98 Bad Record at 65 0 Bad Record at 2 0 Bad Record at 8 0 Bad Record at 60 0 Bad Record at 96 97 Bad Record at 45 0 $ g77 -v Reading specs from /usr/lib/gcc/i486-linux-gnu/3.4.6/specs Configured with: ../src/configure -v --enable-languages=c,c++,f77,pascal --prefix=/usr --libexecdir=/usr/lib --with-gxx-include-dir=/usr/include/c++/3.4 --enable-shared --with-system-zlib --enable-nls --without-included-gettext --program-suffix=-3.4 --enable-__cxa_atexit --enable-clocale=gnu --enable-libstdcxx-debug --with-tune=i686 i486-linux-gnu Thread model: posix gcc version 3.4.6 (Debian 3.4.6-1) $ gfortran -v Using built-in specs. Target: i686-pc-linux-gnu Configured with: ../../gcc/trunk/configure --prefix=/home/ig25 --enable-languages=c,fortran Thread model: posix gcc version 4.2.0 20060525 (experimental) -- tkoenig at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |tkoenig at gcc dot gnu dot | |org OtherBugsDependingO| |19292 nThis| | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27757