This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[gfortran] patch for PR 15113 - reading with A edit descriptormisc problems


These problems came from NIST test FM405.

Two problems, one PR:

first is this
  
       character*16 C
       character*4 D
       data C / 'ABCDEFGHIJKLMNOP'/
       read(C,'(A7)')D
       print*,D
       end

which should print 'DEFG' but instead prints 'ABCD'

and second is this

       character*8 A
       data A /'12345678'/
       character*4 B
       read(A,'(A)')B
       print*,B
       end
which should print "1234' but instead prints "Segmentation fault (core dumped)" 

read_a just needed some logic to handle these two cases.

test FM405 still has other failures, but FM402 now passes.

no additional test suite failures, tested i686/gnu/linux FC1


--bud


test suite file:

! pr 15113
! Ax edit descriptor x larger than destination
! A edit descriptor with no field width segfaults
       character*16 C
       character*4 D
       data C / 'ABCDEFGHIJKLMNOP'/
       read(C,'(A7)')D
       if (D.NE.'DEFG') then
!         print*,D
          call abort
       endif
       read(C,'(A)')D
       if (D.NE.'ABCD') then
!         print*,D
          call abort
       endif
       end

Change Log

2004-04-24  Bud Davis

	PR fortran/15113
	* io/read.c(read_a): Handle field width > destination and no field width.



Index: gcc/libgfortran/io/read.c
===================================================================
RCS file: /cvs/gcc/gcc/libgfortran/io/Attic/read.c,v
retrieving revision 1.1.2.6
diff -c -3 -p -r1.1.2.6 read.c
*** gcc/libgfortran/io/read.c   1 Apr 2004 01:32:46 -0000       1.1.2.6
--- gcc/libgfortran/io/read.c   24 Apr 2004 11:21:45 -0000
*************** read_a (fnode * f, char *p, int length)
*** 283,291 ****
--- 283,296 ----
    int w, m, n;
   
    w = f->u.w;
+   if (w == -1) /* '(A)' edit descriptor  */
+     w = length;
+
    source = read_block (&w);
    if (source == NULL)
      return;
+   if (w > length)
+      source += (w - length);
   
    m = (w > length) ? length : w;
    memcpy (p, source, m);




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]