[PATCH] fortran/28213 -- Fix Hollerith in IO list

Steve Kargl sgk@troutmask.apl.washington.edu
Tue Jul 4 21:22:00 GMT 2006


On Tue, Jul 04, 2006 at 08:21:54AM -0700, Steve Kargl wrote:
> On Tue, Jul 04, 2006 at 10:26:55PM +0800, Feng Wang wrote:
>> 
>> --- Jerry DeLisle <jvdelisle@verizon.net>????:
>> 
>>> Steve Kargl wrote:
>>>> The following patch fixes an ICE when a Hollerith constant
>>>> appears in an IO list.  For some reason, the attached test
>>>> is not caught by DejaGNU.  I ping Janis for advice on the
>>>> test.  I would like to commit the patch even without a test,
>>>> and then commit the test once Janis and I have exchanged 
>>>> some thoughts.
>>>> 
>>> 
>>> If you will accept my review on this, its simple enough and looks OK to
>>> commit.
>>> 
>> 
>> Yes, it's simple. But the way is wrong. Hollerith constant should be accepted
>> to print. Just try this enclosed patch.
>> 
> 
>>From Fortran 66, 5.1.1.6, page 10.
> 
>   "This type of constant may be written only in the argument list
>    of a CALL statement and in the data initialization statement."
> 
> There is an ambiguity with a Hollerith constant in an output statement.
> 
>       program z
>       data i/3horz/
>       data x/3horz/
>       print *, i, x
> c What value should the following list-directed print statement print?
> c     print *, 3horz
>       end
> 
> Furthermore, see section A2, "Conflicts with ANSI X3.9-1966,"
> of the Fortran 77 standard.  Item (3) says "Hollerith constants
> and Hollerith data are not permitted in this standard."  However,
> Appendix C, address the use of Hollerith in a Fortran 77 
> program.  In particular, section C6 address IO with the A edit
> descriptor, but my interpretation (which is sometimes known to
> be too strict and/or wrong) is that a "print '(A3)', 3horz' is
> not permitted.
> 
> Finally, the behavior I implemented is consistent with NAG's
> Fortran 95 compiler.

Sigh.  g77 does something completely different from your patch and
from mine.

atlas:kargl[203] g77 -o z z.f
atlas:kargl[204] ./z
 544895599  2.12136866E-19
 544895599
orz
atlas:kargl[205] cat z.f
      program z
      data i/3horz/
      data x/3horz/
      print *, i, x
      print *, 3horz
      print '(A3)', i
      end

g77 converts the Hollerith constant to an integer in list-directed
output.  This means we probably need to implement the g77 behavior
for backwards compatibility.

-- 
Steve



More information about the Fortran mailing list