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 PR libfortran/19155


I propose this patch to fix PR libfortran/19115. With this patch, the I/O library accepts 'E+00' as a valid real number (with value 0.0). The standard says it is not a valid real number, but doesn't require an error.

Reasons for this choice: g77 accepts it, as well as numerous other Fortran compilers (Intel, Portland, Sun, IBM). It is even part of the NIST testsuite (one of the last NIST failures for gfortran).

Regtested on i386-linux. OK for mainline and 4.0?
2005-05-09  Francois-Xavier Coudert  <coudert@clipper.ens.fr>

	PR libfortran/19155
	* io/read.c (read_f): Accept 'e', 'E', 'd' and 'D' as first
	non-blank characters of a real number.


2005-05-09  Francois-Xavier Coudert  <coudert@clipper.ens.fr>

	PR libfortran/19155
	* gfortran.dg/pr19155.f: New test.
Index: libgfortran/io/read.c
===================================================================
RCS file: /cvsroot/gcc/gcc/libgfortran/io/read.c,v
retrieving revision 1.8
diff -p -u -r1.8 read.c
--- libgfortran/io/read.c	25 Jan 2005 21:40:25 -0000	1.8
+++ libgfortran/io/read.c	9 May 2005 09:31:05 -0000
@@ -538,7 +538,8 @@ read_f (fnode * f, char *dest, int lengt
 
   /* A digit (or a '.') is required at this point */
 
-  if (!isdigit (*p) && *p != '.')
+  if (!isdigit (*p) && *p != '.' && *p != 'd' && *p != 'D'
+      && *p != 'e' && *p != 'E')
     goto bad_float;
 
   /* Remember the position of the first digit.  */
! { dg-do run }
!
! PR libfortran/19155
! We accept 'E+00' as a valid real number. The standard says it is not,
! but doesn't require us to issue an error. Since g77 accepts this as zero,
! we do the same.
      real a
      a = 42
      open (19,status='scratch')
      write (19,'(A15)') 'E+00'
      rewind (19)
      read (19,'(E15.8)') a
      if (a .ne. 0) call abort
      close (19)
      end

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