https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114618
Bug ID: 114618 Summary: Format produces incorrect output when contains 1x, ok when uses " " Product: gcc Version: 13.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: urbanjost at comcast dot net Target Milestone: --- The format gen2 does what I would expect the format gen1 does, but get very strange output when use 1x (in gen1) instead of space character (in gen2). program tryit implicit none integer, parameter :: wp = kind(0d0) real(kind=wp) :: pi = 3.14159265358979323846264338327950288419716939937510582097494459230_wp character(len=*), parameter:: gen1 = '(19("."),t1,g0,1x,t21,g0)' character(len=*), parameter:: gen2 = '(19("."),t1,g0," ",t21,g0)' character(len=:), allocatable :: fmt integer :: i, j do i=1,2 select case(i) case(1); fmt=gen1 case(2); fmt=gen2 end select do j=1,2 write (*, fmt) 'PI', pi write (*, fmt) 'REAL(PI)', real(pi) write (*, fmt) 'DBLE(PI)', dble(pi) write (*, fmt) 'RADIX', radix(pi) write (*, fmt) 'RANGE', range(pi) write (*, fmt) 'PRECISION', precision(pi) write (*,'(80("-"))') enddo enddo end program tryit PI.................^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@ 3.1415926535897931 REAL(PI)...........^@^@^@^@^@^@^@^@^@^@^@ 3.14159274 DBLE(PI)...........^@^@^@^@^@^@^@^@^@^@^@ 3.1415926535897931 RADIX..............^@^@^@^@^@^@^@^@^@^@^@ 3. 2 RANGE..............^@^@^@^@^@^@^@^@^@^@^@ 3. 307 PRECISION..........^@^@^@^@^@^@^@^@^@^@ 15 -------------------------------------------------------------------------------- PI.................----------------- 3.1415926535897931 REAL(PI)...........----------- 3.14159274 DBLE(PI)...........----------- 3.1415926535897931 RADIX..............----------- 3. 2 RANGE..............----------- 3. 307 PRECISION..........---------- 15 -------------------------------------------------------------------------------- PI ................ 3.1415926535897931 REAL(PI) .......... 3.14159274 DBLE(PI) .......... 3.1415926535897931 RADIX ............. 2 RANGE ............. 307 PRECISION ......... 15 -------------------------------------------------------------------------------- PI ................ 3.1415926535897931 REAL(PI) .......... 3.14159274 DBLE(PI) .......... 3.1415926535897931 RADIX ............. 2 RANGE ............. 307 PRECISION ......... 15 --------------------------------------------------------------------------------