------- Comment #7 from jvdelisle at gcc dot gnu dot org  2009-04-29 03:38 
-------
Notice what gfortran does with this modified from the original test case:

read(str,'(i1)') a

 ./a.out 
           0

Here we properly pad as expected.  Now, the subtlety here is: should we provide
positioning into a zero length file, into non existent space.  Seems absurd to
me. I understand the text that Dick is pointing out, but I do not believe the
standards committee implied that one can position a file past its end.

Notice the standard gives the condition "if an input item and its corresponding
data edit descriptor require more characters from the record than the record
contains."

The input item is the integer 'a', its corresponding edit descriptor is 'i1'

The original case is:

read(str,'(5x,i1)') a

'5x' is not the (singular) corresponding edit descriptor for the input item 'a'

'5x' is a control edit descriptor and not a data edit descriptor.

F2003 Standard 10.7.1  "The position specified by an X edit descriptor is
forward from the current position. On input, a position beyond the last
character of the record may be specified if no characters are transmitted from
such positions."

I will argue that we are attempting to transmit a character from such position
and therefore the original test case is invalid.

I also see that one could choose to interpret that since there are no
characters at this position, one is not attempting to read any, and indeed we
are not, therefore its OK to position past the end.

I will then counter it is a fact this is a read statement with a valid list
item, the integer 'a', this is indeed an attempt to transmit a character from
an invalid position.

Gads, I am not a lawyer.  However, by my argument, if I change the string to
contain 5 characters, the read should be valid with padding.  gfortran does not
get that part right.

So, we need to do something about this.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39587

Reply via email to