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

            Bug ID: 109358
           Summary: Wrong formatting with T-descriptor during stream
                    output
           Product: gcc
           Version: 12.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: baradi09 at gmail dot com
  Target Milestone: ---

This is a very minor bug, but probably easy to fix. It seems, that the T data
edit descriptor handling is non-standard conforming when using formatted stream
I/O:

Given the following MWE:

program tabformat
  implicit none

  integer :: fd

  open(newunit=fd, file="test.stream.txt", access="stream", form="formatted")  
  write(fd, "(a)") "1234567890123"
  write(fd, "(a, t10, a)") "1234", "0123"  ! A-descriptor, file positioning
allowed                                 
  write(fd, "(i4, t10, i4.4)") 1234, 0123  !  I-descriptor, file positioning
not allowed                               
  close(fd)

end program tabformat

The resulting file contains

1234567890123
1234         0123   # 9 spaces between blocks
1234         0123   # 9 spaces between blocks

Apparently, a file positioning takes place during the execution of the write
statement. 

However, if I understand 13.7.1 ยง1 correctly, file positioning may only happen
with the A-descriptor (and it is optional even there). So the standard
conforming output would be either (if file positioning happens after the
A-descriptor)

1234567890123
1234         0123    # 9 spaces
1234     0123        # 5 spaces

or (if no file positioning happens after the A-descriptor)

1234567890123
1234     0123        # 5 spaces
1234     0123        # 5 spaces

I personally would prefer latter, and it would be also equivalent to the
behavior of the Intel and NAG compilers.

Reply via email to