https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109358

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |anlauf at gcc dot gnu.org
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |---

--- Comment #15 from anlauf at gcc dot gnu.org ---
Jerry, I tend to think the fix does not cover loopholes like multiple
tabbing or nX without printing anything in between.

Consider the enhanced test:

program tabs
  implicit none
  integer :: fd
  open(newunit=fd, file="test-stream.txt", form="formatted", access="stream")
  write(fd, "(a)") "12345678901234567890123456789"
  write(fd, "(i4, t25, t2, i4.4)") 1234, 0123             ! wrong
  write(fd, "(i4, t25, 1x, t2, i4.4)") 1234, 0123         ! wrong
  write(fd, "(i4, t21, a,  t2, i4.4)") 1234, "good", 0123 ! OK
  write(fd, "(i4, t40, i4, t20, i5.5)") 1234, 5555, 67890 ! OK
  close(fd)
  open(newunit=fd, file="test.txt", form="formatted")
  write(fd, "(a)") "12345678901234567890123456789"
  write(fd, "(i4, t25, t2, i4.4)") 1234, 0123             ! wrong
  write(fd, "(i4, t25, 1x, t2, i4.4)") 1234, 0123         ! wrong
  write(fd, "(i4, t21, a,  t2, i4.4)") 1234, "good", 0123 ! OK
  write(fd, "(i4, t40, i4, t20, i5.5)") 1234, 5555, 67890 ! OK
  close(fd)
end program tabs

Expected:

==> test-stream.txt <==
12345678901234567890123456789
10123
10123
10123               good
1234               67890               5555

==> test.txt <==
12345678901234567890123456789
10123
10123
10123               good
1234               67890               5555

With gcc-13/gcc-14 after your patch I get:

==> test-stream.txt <==
12345678901234567890123456789
1234                0123
1234                 0123
10123               good
1234               67890               5555

==> test.txt <==
12345678901234567890123456789
1234                0123
1234                 0123
10123               good
1234               67890               5555

Can you have a further look?

Reply via email to