[patch, gfortran] pr22570 and related issues.

Jack Howarth howarth@bromo.msbb.uc.edu
Wed Jul 27 03:37:00 GMT 2005


Paul,
   Could you check the patch against 4.0 branch? The version I came up
with that would apply against the 20050721 4.0 snapshot was...

--- gcc-4.0-20050721/libgfortran/io/transfer.c.org      2005-07-26 22:49:12.0000
00000 -0400
+++ gcc-4.0-20050721/libgfortran/io/transfer.c  2005-07-26 22:53:56.000000000 -0
400
@@ -482,14 +482,24 @@
       /* Now discharge T, TR and X movements to the right.  This is delayed
         until a data producing format to supress trailing spaces.  */
       t = f->format;
-      if (g.mode == WRITING && skips > 0
-       &&    (t == FMT_I || t == FMT_B || t == FMT_O || t == FMT_Z
-           || t == FMT_F || t == FMT_E || t == FMT_EN || t == FMT_ES
-           || t == FMT_G || t == FMT_L || t == FMT_A || t == FMT_D
+       if (g.mode == WRITING && skips != 0
+       && ((n>0 && (  t == FMT_I  || t == FMT_B  || t == FMT_O
+                   || t == FMT_Z  || t == FMT_F  || t == FMT_E
+                   || t == FMT_EN || t == FMT_ES || t == FMT_G
+                   || t == FMT_L  || t == FMT_A  || t == FMT_D))
+
            || t == FMT_STRING))
        {
-         write_x (skips, pending_spaces);
-         max_pos = current_unit->recl - current_unit->bytes_left;
+         if (skips > 0)
+           {
+             write_x (skips, pending_spaces);
+             max_pos = (int)(current_unit->recl - current_unit->bytes_left);
+           }
+         if (skips < 0)
+           {
+             move_pos_offset (current_unit->s, skips);
+             current_unit->bytes_left -= (gfc_offset)skips;
+           }
          skips = pending_spaces = 0;
        }
 
@@ -722,19 +732,19 @@
 
          /* Writes occur just before the switch on f->format, above, so that
             trailing blanks are suppressed.  */
-         if (skips > 0)
+         if (g.mode == READING)
            {
-             if (g.mode == READING)
+             if (skips > 0)
                {
                  f->u.n = skips;
                  read_x (f);
                }
-           }
-         if (skips < 0)
-           {
-             move_pos_offset (current_unit->s, skips);
-             current_unit->bytes_left -= skips;
-             skips = pending_spaces = 0;
+             if (skips < 0)
+               {
+                 move_pos_offset (current_unit->s, skips);
+                 current_unit->bytes_left -= (gfc_offset)skips;
+                 skips = pending_spaces = 0;
+               }
            }
 
        break;
@@ -776,6 +786,7 @@
 
        case FMT_SLASH:
          consume_data_flag = 0 ;
+          skips = pending_spaces = 0;
          next_record (0);
          break;
 
@@ -814,7 +825,7 @@
       if (g.mode == READING)
        skips = 0;
 
-      pos = current_unit->recl - current_unit->bytes_left;
+      pos = (int)(current_unit->recl - current_unit->bytes_left);
       max_pos = (max_pos > pos) ? max_pos : pos;
 
     }


With this patch applied, my formatbug.f test case no longer outputs
the trailing space, however the testcase you submitted with the patch
still aborts. Using this build of gfortran I find that the following
NIST tests fail...

FM001.res
FM103.res
FM104.res
FM105.res
FM402.res
FM912.res

I also notice another oddity. When I run the driver_run script using g95
as the compiler, I can execute...

grep FAIL *.res | more

and see the all of the matches. However if I do the same for a gfortran
build, I find that some of the files being grep'd are reported as...

Binary file FM907.res matches

etc. Interestingly if I do "file FM907.res" in each fcvs21_f95 directory,
the g95 build directory reports...

FM907.res: ASCII text

whereas the gfortran build directory reports...

FM907.res: data

This appears to be because the gfortran generated FM907.res contains...

 TEST   PASS/FAIL       DISPLAYED RESULTS       REMARKS
 -------------------------------------------------------------------------------
                                                 THIS PROGRAM HAS   8 TESTS

                                                 THE CORRECT LINE OF EACH TEST  
 ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@IS HOLLERITH INFORMATION.  
    
 ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@COLUMN SPACING,  LINE BREAK
S,  
 ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@AND THE NUMBER OF DECIMAL  
    
 ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@PLACES FOR DOUBLE PRECISION
    
 ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@OR COMPLEX NUMBERS ARE     
    
 ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@PROCESSOR DEPENDENT.       
    
 ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@EITHER E OR F FORMAT MAY BE
    
 ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@USED FOR DOUBLE PRECISION O
R   
 ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@COMPLEX NUMBERS.           
    

Are you seeing this issue?
            Jack



More information about the Fortran mailing list