[Bug libfortran/23321] New: Direct unformatted read beyond EOF cores

2005-08-10 Thread bsp at kithrup dot com
c  Summary: Direct unformatted read beyond EOF cores

c  This program demonstrates a bug in gfortran/libgfortran.
c  The bug is that a
c  program dumps core when reading beyond the end of
c  a access='direct', form='unformatted' file instead
c  of transfering control to 'err=' label.
c  Also, returns incorrectly when reading at end of file.

c  To test
cdd if=/dev/zero of=shortfile bs=11811 count=1
c./a.out
cBus error (core dumped)
cdd if=/dev/zero of=shortfile bs=11812 count=1
c./a.out
cshould not get here
cbefore 779 inbuf(1)=   32
cSTOP 0

cNote: in the above case, the value of inbuf(1) got set to a space

c  When compiled with ifort or g77, the correct output is produced
c  in both cases.
c./a.out
cat 779, all is good

c  Problem occurs in
cGNU Fortran 95 (GCC 4.0.1)
cGNU Fortran 95 (GCC 4.0.2 20050804 (prerelease))
cGNU Fortran 95 (GCC 4.1.0 20050806 (experimental))

c gfortran -v
c Using built-in specs.
c Target: i686-pc-linux-gnu
c Configured with: ../../NetSrc/gcc-4.1-20050806/configure 
--prefix=/home/bswift/afrl/
builddev/NetInst/gcc-4.1-20050806 --enable-languages=c,f95 
--with-gmp=/home/bswift/afrl/
builddev/NetInst/gmp-4.1.4 
--with-mpfr=/home/bswift/afrl/builddev/NetInst/mpfr-2.1.2
c Thread model: posix
c gcc version 4.1.0 20050806 (experimental)

  implicit none

  integernbytes

  integer inbuflen
  parameter (inbuflen=32768)
  integer*1  inbuf(inbuflen)
  integer k

  inbuf(1)=5

  nbytes=11812

  open(35,file='shortfile',access='direct',recl=nbytes,form
 $ ='unformatted')

  read(35,rec=2,err=779) (inbuf(k),k=1,nbytes)

  write(*,*) 'should not get here'
  write(*,*) 'before 779 inbuf(1)=',inbuf(1)
  stop
 779  write(*,*) 'at 779, all is good'
  end

-- 
   Summary: Direct unformatted read beyond EOF cores
   Product: gcc
   Version: 4.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P2
 Component: libfortran
        AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: bsp at kithrup dot com
CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23321


[Bug fortran/20811] gfortran include problem (regression from g77)

2005-08-16 Thread bsp at kithrup dot com

--- Additional Comments From bsp at kithrup dot com  2005-08-16 16:37 
---
FYI, ifort_8.0.046, Absoft Fortran 95 9.0 EP, pgf95 6.0-2, SGI f90 7.4, and g95
will all find and use the included file in the same directory as the source
without requiring extra '-I' command line options.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20811