https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80727
Bug ID: 80727 Summary: Crash of runtime gfortran library during integer transformation Product: gcc Version: 7.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libfortran Assignee: unassigned at gcc dot gnu.org Reporter: user1 at lpetrov dot net Target Milestone: --- Dear gcc developers, Thank for maintaining the gcc collection. Recently I compiled from sources gcc 7.1.0 and I found a bug in gfortran IO library. That example works correctly under gcc 5.1.0 and 6.1.0 See below: 1) source file gfortran_710_io_bug.f 2) gfortran_710_io_bug.comp -- result of command line gfortran -v -save-temps -fno-underscoring -ffree-form -o gfortran_710_io_bug.e gfortran_710_io_bug.f 3) gfortran_710_io_bug.out -- result of running affected program: ./gfortran_710_io_bug.e /tmp> uname -a Linux astrogeo 4.10.0 #2 SMP Thu Feb 23 09:59:20 EST 2017 x86_64 x86_64 x86_64 GNU/Linux Sincerely, Leonid Petrov 2017.05.12_11:48:39 1) Source code code that triggers the bug: PROGRAM GFORTRAN_710_IO_BUG CHARACTER STR*4 INTEGER*4 I4 LOGICAL*1 FL_SHOW_BUG ! FL_SHOW_BUG = .TRUE. STR = CHAR(0)//CHAR(1)//CHAR(0)//CHAR(0) IF ( FL_SHOW_BUG ) THEN ! ! -------- The place where gfortran 7.1.0 crashes ! READ ( UNIT=STR(1:4), FMT='(A4)' ) I4 ELSE ! ! -------- Workaround ! CALL MEMCPY ( I4, %REF(STR), %VAL(4) ) END IF WRITE ( 6, * ) ' I4= ', I4 END PROGRAM GFORTRAN_710_IO_BUG 2) Output of the command line gfortran -v -save-temps -fno-underscoring -ffree-form -o gfortran_710_io_bug.e gfortran_710_io_bug.f Driving: gfortran -v -save-temps -fno-underscoring -ffree-form -o gfortran_710_io_bug.e gfortran_710_io_bug.f -l gfortran -l m -shared-libgcc Using built-in specs. COLLECT_GCC=gfortran COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/7.1.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../configure --prefix=/usr --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-multilib --enable-lto --without-isl --enable-languages=c,c++,fortran,objc,obj-c++ Thread model: posix gcc version 7.1.0 (GCC) COLLECT_GCC_OPTIONS='-v' '-save-temps' '-fno-underscoring' '-ffree-form' '-o' 'gfortran_710_io_bug.e' '-shared-libgcc' '-mtune=generic' '-march=x86-64' /usr/libexec/gcc/x86_64-pc-linux-gnu/7.1.0/f951 gfortran_710_io_bug.f -quiet -dumpbase gfortran_710_io_bug.f -mtune=generic -march=x86-64 -auxbase gfortran_710_io_bug -version -fno-underscoring -ffree-form -fintrinsic-modules-path /usr/lib64/gcc/x86_64-pc-linux-gnu/7.1.0/finclude -o gfortran_710_io_bug.s GNU Fortran (GCC) version 7.1.0 (x86_64-pc-linux-gnu) compiled by GNU C version 7.1.0, GMP version 6.0.0, MPFR version 3.1.2, MPC version 1.0.2, isl version none GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 GNU Fortran2008 (GCC) version 7.1.0 (x86_64-pc-linux-gnu) compiled by GNU C version 7.1.0, GMP version 6.0.0, MPFR version 3.1.2, MPC version 1.0.2, isl version none GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 COLLECT_GCC_OPTIONS='-v' '-save-temps' '-fno-underscoring' '-ffree-form' '-o' 'gfortran_710_io_bug.e' '-shared-libgcc' '-mtune=generic' '-march=x86-64' as -v --64 -o gfortran_710_io_bug.o gfortran_710_io_bug.s GNU assembler version 2.24 (x86_64-redhat-linux) using BFD version version 2.24 Reading specs from /usr/lib64/gcc/x86_64-pc-linux-gnu/7.1.0/../../../../lib64/libgfortran.spec rename spec lib to liborig COLLECT_GCC_OPTIONS='-v' '-save-temps' '-fno-underscoring' '-ffree-form' '-o' 'gfortran_710_io_bug.e' '-shared-libgcc' '-mtune=generic' '-march=x86-64' COMPILER_PATH=/usr/libexec/gcc/x86_64-pc-linux-gnu/7.1.0/:/usr/libexec/gcc/x86_64-pc-linux-gnu/7.1.0/:/usr/libexec/gcc/x86_64-pc-linux-gnu/:/usr/lib64/gcc/x86_64-pc-linux-gnu/7.1.0/:/usr/lib64/gcc/x86_64-pc-linux-gnu/ LIBRARY_PATH=/usr/lib64/gcc/x86_64-pc-linux-gnu/7.1.0/:/usr/lib64/gcc/x86_64-pc-linux-gnu/7.1.0/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/usr/lib64/gcc/x86_64-pc-linux-gnu/7.1.0/../../../:/lib/:/usr/lib/ COLLECT_GCC_OPTIONS='-v' '-save-temps' '-fno-underscoring' '-ffree-form' '-o' 'gfortran_710_io_bug.e' '-shared-libgcc' '-mtune=generic' '-march=x86-64' /usr/libexec/gcc/x86_64-pc-linux-gnu/7.1.0/collect2 -plugin /usr/libexec/gcc/x86_64-pc-linux-gnu/7.1.0/liblto_plugin.so -plugin-opt=/usr/libexec/gcc/x86_64-pc-linux-gnu/7.1.0/lto-wrapper -plugin-opt=-fresolution=gfortran_710_io_bug.res -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lquadmath -plugin-opt=-pass-through=-lm -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o gfortran_710_io_bug.e /usr/lib64/gcc/x86_64-pc-linux-gnu/7.1.0/../../../../lib64/crt1.o /usr/lib64/gcc/x86_64-pc-linux-gnu/7.1.0/../../../../lib64/crti.o /usr/lib64/gcc/x86_64-pc-linux-gnu/7.1.0/crtbegin.o -L/usr/lib64/gcc/x86_64-pc-linux-gnu/7.1.0 -L/usr/lib64/gcc/x86_64-pc-linux-gnu/7.1.0/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib64/gcc/x86_64-pc-linux-gnu/7.1.0/../../.. gfortran_710_io_bug.o -lgfortran -lm -lgcc_s -lgcc -lquadmath -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib64/gcc/x86_64-pc-linux-gnu/7.1.0/crtend.o /usr/lib64/gcc/x86_64-pc-linux-gnu/7.1.0/../../../../lib64/crtn.o COLLECT_GCC_OPTIONS='-v' '-save-temps' '-fno-underscoring' '-ffree-form' '-o' 'gfortran_710_io_bug.e' '-shared-libgcc' '-mtune=generic' '-march=x86-64' 3) result of running affected program: ./gfortran_710_io_bug.e At line 12 of file gfortran_710_io_bug.f Fortran runtime error: End of record Error termination. Backtrace: #0 0x7f50ed383df2 in read_sf at ../../../libgfortran/io/transfer.c:368 #1 0x7f50ed380aff in read_default_char1 at ../../../libgfortran/io/read.c:421 #2 0x7f50ed3851bc in formatted_transfer_scalar_read at ../../../libgfortran/io/transfer.c:1584 #3 0x7f50ed38603c in formatted_transfer at ../../../libgfortran/io/transfer.c:2263 #4 0x4009f0 in ??? #5 0x400ad2 in ??? #6 0x7f50ec6fefdf in ??? #7 0x400898 in ??? #8 0xffffffffffffffff in ???