Jerry,

while I haven't read your actual patch yet, I think the testcase
is slightly incorrect. In fact, Intel, NAG, Nvidia and AMD flang
disagree with it.

Adding the following lines before the check with the STOP statement:

write(*,'(a)') output1
write(*,'(a)') output2
write (*, fmt1) 'RADIX', radix(pi)
write (*, fmt2) 'RADIX', radix(pi)

I get (e.g. with NAG):

RADIX.............. 2
RADIX ............. 2
RADIX.............. 2
RADIX ............. 2
STOP: 1

After your patch I get with gfc-15:

RADIX ............. 2
RADIX ............. 2
RADIX ............. 2
RADIX ............. 2

So I think the treatment of 1x is wrong: it should skip one position,
not write a blank here.

>>>

F2023 13.8.1.3   X editing

The nX edit descriptor indicates that the transmission of the next
character to or from a record is to occur at
the character position n characters forward from the current position.

NOTE
An nX edit descriptor has the same effect as a TRn edit descriptor.

<<<

Cheers,
Harald


Am 28.01.25 um 04:41 schrieb Jerry D:
Hello all,

The attached patch is part 1 of my effort to fix these X and T edit
descriptor issues. This one cleans up some really ugly output.

Before the patch with the test case provided by the reporter:

PI.................^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@ 3.1415926535897931
REAL(PI)...........^@^@^@^@^@^@^@^@^@^@^@ 3.14159274
DBLE(PI)...........^@^@^@^@^@^@^@^@^@^@^@ 3.1415926535897931
RADIX..............^@^@^@^@^@^@^@^@^@^@^@ 3. 2
RANGE..............^@^@^@^@^@^@^@^@^@^@^@ 3. 307
PRECISION..........^@^@^@^@^@^@^@^@^@^@ 15

Which is complete garbage.

After the patch:

PI ................ 3.1415926535897931
REAL(PI) .......... 3.14159274
DBLE(PI) .......... 3.1415926535897931
RADIX ............. 2
RANGE ............. 307
PRECISION ......... 15

I greatly reduced the test case included in the patch. While working on
this one I discovered other problems not addressed by this patch and I
will address these through PR113897.

You will see some changes in the factoring of some of the code in the
case FMT_X:, case FMT_TR:, case FMT_TL:, case FMT_T:. I anticipate in
part 2 that I will be doing more specific changes on these.

Regression tested on x86_64_linux_gnu.

OK for trunk?

Regards,

Jerry

Author: Jerry DeLisle <jvdeli...@gcc.gnu.org>
Date:   Mon Jan 27 19:08:46 2025 -0800

     Fortran: Fix handling of the X edit descriptor.

     This patch is a partial fix of handling of X edit descriptors
     when combined with certain T edit descriptors.

             PR libfortran/114618

     libgfortran/ChangeLog:

           * io/transfer.c (formatted_transfer_scalar_write): Change name
             of vriable 'pos' to 'tab_pos' to improve clarity. Add new
             variable next_pos when calculating the maximum position.
             Update the calculation of pending spaces.

     gcc/testsuite/ChangeLog:

             * gfortran.dg/pr114618.f90: New test.


Reply via email to