$ cat a.f character*16 C character*4 D data C / 'ABCDEFGHIJKLMNOP'/ read(C,'(A7)')D print*,D end $ gfortran -g -static a.f $ ./a.out ABCD $ g77 a.f $ ./a.out DEFG [bdavis@localhost fm411]$ gfortran --version GNU Fortran 95 (GCC 3.5-tree-ssa 20040424 (merged 20040414))
very closely related is this problem, which can probably be fixed at the same time: $ cat b.f character*8 A data A /'12345678'/ character*4 B read(A,'(A)')B print*,B end $ /usr/local/bin/current/bin/gfortran -static b.f $ ./a.out Segmentation fault (core dumped) $ g77 b.f $ ./a.out 1234
Subject: Bug 15113 CVSROOT: /cvs/gcc Module name: gcc Branch: tree-ssa-20020619-branch Changes by: bdavis@gcc.gnu.org 2004-04-24 12:11:48 Modified files: libgfortran : ChangeLog libgfortran/io : read.c gcc/testsuite : ChangeLog.tree-ssa Added files: gcc/testsuite/gfortran.fortran-torture/execute: a_edit_1.f90 Log message: PR fortran/15113 * gfortran.fortran-torture/execute/a_edit_1.f90: Add new test. * io/read.c(read_a): Handle field width > destination and no field width. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/ChangeLog.diff?cvsroot=gcc&only_with_tag=tree-ssa-20020619-branch&r1=1.1.2.45&r2=1.1.2.46 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libgfortran/io/read.c.diff?cvsroot=gcc&only_with_tag=tree-ssa-20020619-branch&r1=1.1.2.6&r2=1.1.2.7 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.fortran-torture/execute/a_edit_1.f90.diff?cvsroot=gcc&only_with_tag=tree-ssa-20020619-branch&r1=NONE&r2=1.1.2.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.tree-ssa.diff?cvsroot=gcc&only_with_tag=tree-ssa-20020619-branch&r1=1.1.2.227&r2=1.1.2.228
Fixed.