[Bug fortran/61628] New: A program that reads from a file with stream access and uses pack() suddenly stops

arjen.markus895 at gmail dot com gcc-bugzilla@gcc.gnu.org
Fri Jun 27 10:49:00 GMT 2014


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61628

            Bug ID: 61628
           Summary: A program that reads from a file with stream access
                    and uses pack() suddenly stops
           Product: gcc
           Version: 4.8.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: arjen.markus895 at gmail dot com

Created attachment 33016
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33016&action=edit
Example data file as used in the program, compressed

The following program suddenly stops after the statement with pack() -- without
any message -- but it continues if you comment out the read statement:

! readprint.f90 --
!     Read and print some data from a binary file
!
program readprint
    implicit none

    integer                            :: noseg, nx, ny, dummy, i
    integer, dimension(:), allocatable :: matrix

    open( 10, file = 'binary_data', form = 'unformatted', access = 'stream' )
    read( 10 ) nx, ny, (dummy, i = 1,4)

    allocate( matrix(nx*ny) )

!
! If the READ statement is commented, then the program continues, otherwise
! it stops without any message
!
    read( 10 ) matrix
    write(*,*) nx, ny, size(matrix)
    write(*,*) pack( matrix, matrix /= 1 )
    write(*,*) matrix(1:1000)
    write(*,*) 'done'

end program readprint

I have not tried this on another data file, but the behaviour is odd enough
that I want to report this.

Note: gfortran -v gives:

Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/4.8.1/lto-wrapper.exe
Target: mingw32
Configured with: ../gcc-4.8.1/configure --prefix=/mingw --host=mingw32
--build=mingw32 --without-pic --enable-shared --enable-static --with-gnu-ld
--enable-lto --enable-libssp --disable-multilib
--enable-languages=c,c++,fortran,objc,obj-c++,ada --disable-sjlj-exceptions
--with-dwarf2 --disable-win32-registry --enable-libstdcxx-debug
--enable-version-specific-runtime-libs
--with-gmp=/usr/src/pkg/gmp-5.1.2-1-mingw32-src/bld
--with-mpc=/usr/src/pkg/mpc-1.0.1-1-mingw32-src/bld --with-mpfr=
--with-system-zlib --with-gnu-as --enable-decimal-float=yes --enable-libgomp
--enable-threads --with-libiconv-prefix=/mingw32 --with-libintl-prefix=/mingw
--disable-bootstrap LDFLAGS=-s CFLAGS=-D_USE_32BIT_TIME_T
Thread model: win32
gcc version 4.8.1 (GCC)



More information about the Gcc-bugs mailing list