This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran 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]

Re: [PATCH] Fix FMT= with CHARACTER arrays (PR fortran/39865, take 3)


Jakub Jelinek wrote:
> On Wed, May 13, 2009 at 10:22:37PM +0200, Dominique Dhumieres wrote:
>   
>> Sorry about that, but I think the Hollerith extension of take 4 is wrong:
>>
>> character(4) :: b(1,3)
>> integer(4)   :: a(1,3)
>> a(1,1) = 4HXXXX
>> a(1,2) = 4H (8I
>> a(1,3) = 2H4)
>> write(*, fmt=a(1,2)) 1, 2, 3, 4, 5, 6, 7, 8
>> b(1,1) = 'XXXX'
>> b(1,2) = ' (8I'
>> b(1,3) = '4)'
>> write(*, fmt=b(1,2)) 1, 2, 3, 4, 5, 6, 7, 8
>> end
>>
>> gives
>>
>>    1   2   3   4   5   6   7   8
>> At line 10 of file wrong_fmt.f90 (unit = 6, file = 'stdout')
>> Fortran runtime error: Nonnegative width required in format
>>  (8I
>>    ^
>>     
ifort 11.1 prints twice the numbers 1 to 8. Same with Portland Group's
pgf95 7.1. It does not compile with sunf95/openf95/pathf95 (which seem
to be based on the same compiler though they diverged quite a bit) nor
with picky NAG f95; with g95 it gives a run-time error (for both examples).

> The b case is mandated by the standard
Well, it fails at run-time with pathf95, sunf95, gfortran (trunk), g95
and NAG f95. The problem seems to be that all those read "(8I". (With
ifort and pgf95 it works as written above.) I have not digged through
the standard to see whether it is indeed standard conform - it probably is.

Tobias


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