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/22436


Attached easy patch fixes bug 22436: default format for real(10) and real(16) can lead to asterisks, in cases such as:

  print *, tiny(0.0_10)
  print *, huge(0.0_10)

The proposed patch uses format 1PG24.15E4 for REAL(10) and 1PG40.31E4 for REAL(16). The formats for other kinds are unchanged: 1PG14.7E2 for REAL(4) and 1PG23.15E3 for REAL(8).

I'm leaving again tomorrow so I won't have time to commit this. So, if nobody objects to this choice of formats, please feel free to commit!

FX
2005-07-19  Francois-Xavier Coudert  <coudert@clipper.ens.fr>

	PR libfortran/22436
	* io/write.c (write_real): Add default formats for real(10) and
	real(16).

Index: write.c
===================================================================
RCS file: /cvsroot/gcc/gcc/libgfortran/io/write.c,v
retrieving revision 1.43
diff -u -3 -p -r1.43 write.c
--- write.c	17 Jul 2005 20:28:14 -0000	1.43
+++ write.c	19 Jul 2005 16:47:35 -0000
@@ -1262,7 +1262,8 @@ write_character (const char *source, int
 
 
 /* Output a real number with default format.
-   This is 1PG14.7E2 for REAL(4) and 1PG23.15E3 for REAL(8).  */
+   This is 1PG14.7E2 for REAL(4), 1PG23.15E3 for REAL(8),
+   1PG24.15E4 for REAL(10) and 1PG40.31E4 for REAL(16).  */
 
 static void
 write_real (const char *source, int length)
@@ -1271,17 +1272,31 @@ write_real (const char *source, int leng
   int org_scale = g.scale_factor;
   f.format = FMT_G;
   g.scale_factor = 1;
-  if (length < 8)
+  switch (length)
     {
+    case 4:
       f.u.real.w = 14;
       f.u.real.d = 7;
       f.u.real.e = 2;
-    }
-  else
-    {
+      break;
+    case 8:
       f.u.real.w = 23;
       f.u.real.d = 15;
       f.u.real.e = 3;
+      break;
+    case 10:
+      f.u.real.w = 24;
+      f.u.real.d = 15;
+      f.u.real.e = 4;
+      break;
+    case 16:
+      f.u.real.w = 40;
+      f.u.real.d = 31;
+      f.u.real.e = 4;
+      break;
+    default:
+      internal_error ("bad real kind");
+      break;
     }
   write_float (&f, source , length);
   g.scale_factor = org_scale;

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