Bug 15113 - formatted reads with A format larger than destination are wrong
Summary: formatted reads with A format larger than destination are wrong
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libfortran (show other bugs)
Version: tree-ssa
: P2 normal
Target Milestone: 4.0.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-04-24 10:37 UTC by bdavis9659
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description bdavis9659 2004-04-24 10:37:34 UTC
$ 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))
Comment 1 bdavis9659 2004-04-24 11:27:17 UTC
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
Comment 2 GCC Commits 2004-04-24 12:11:55 UTC
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

Comment 3 Andrew Pinski 2004-04-24 13:46:21 UTC
Fixed.