[patch, libfortran] PR114618 Format produces incorrect output when contains 1x, ok when uses " "
Jerry D
jvdelisle2@gmail.com
Wed Jan 29 18:30:18 GMT 2025
Follow-up:
On 1/28/25 1:33 PM, Harald Anlauf wrote:
> 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
The following adjustment to the patch puts this right.
case FMT_X:
case FMT_TR:
consume_data_flag = 0;
dtp->u.p.skips += f->u.n;
tab_pos = bytes_used + dtp->u.p.skips - 1;
dtp->u.p.pending_spaces = tab_pos - dtp->u.p.max_pos + 1;
dtp->u.p.pending_spaces = dtp->u.p.pending_spaces < 0
? f->u.n : dtp->u.p.pending_spaces;
//if (t == FMT_X && tab_pos < dtp->u.p.max_pos)
//{
//write_x (dtp, dtp->u.p.skips, dtp->u.p.pending_spaces);
//dtp->u.p.skips = dtp->u.p.pending_spaces = 0;
//}
Interestingly, it also fixes a floating point exception I ran into while
setting up another test case for part 2 of this effort. I suspect this
may be what was detected by the auto patch tester.
I will clean this up, adjust the test case for this part and re-submit.
Regards,
Jerry
More information about the Fortran
mailing list