[Bug libfortran/114618] Format produces incorrect output when contains 1x, ok when uses " "

2024-04-16 Thread jvdelisle at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114618

--- Comment #6 from Jerry DeLisle  ---
Created attachment 57965
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57965=edit
Preliminary patch to fix several issues.

The attached patch is very preliminary and appears to fix the X format issue
and does some code factoring. I have yet to explore the same situation with TR
following the 19 '.' printed.  This also fixes the problem with embedded
garbage in the output.

It does regression test with the new test cases, so getting close.

[Bug libfortran/114618] Format produces incorrect output when contains 1x, ok when uses " "

2024-04-14 Thread jvdelisle at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114618

Jerry DeLisle  changed:

   What|Removed |Added

 Status|REOPENED|NEW
 Depends on||113897, 109358


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109358
[Bug 109358] Wrong formatting with T-descriptor during stream output
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113897
[Bug 113897] Consecutive tab and/or nX edits in format are not processed
correctly.

[Bug libfortran/114618] Format produces incorrect output when contains 1x, ok when uses " "

2024-04-14 Thread jvdelisle at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114618

Jerry DeLisle  changed:

   What|Removed |Added

   Assignee|unassigned at gcc dot gnu.org  |jvdelisle at gcc dot 
gnu.org

--- Comment #5 from Jerry DeLisle  ---
A further reduction:

program tryit
   implicit none
   integer, parameter :: wp = kind(0d0)
   real(kind=wp) :: pi  =
3.14159265358979323846264338327950288419716939937510582097494459230_wp
   character(40) gen1
   character(40) gen2
   gen1 = '(19("."),t1,g0,1x,t21,g0)'
   gen2 = '(19("."),t1,g0," ",t21,g0)'

   write (*, gen1) 'RADIX', radix(pi)
   write (*, gen1) 'RANGE', range(pi)
   write (*,'(80("-"))')
   write (*, gen2) 'RADIX', radix(pi)
   write (*, gen2) 'RANGE', range(pi)
end program tryit

This is indeed ugly. Note the embedded NULLs.

$ ./a.out >newdata
$ xxd newdata
: 5241 4449 582e 2e2e 2e2e 2e2e 2e2e 2e2e  RADIX...
0010: 2e2e 2e00        
0020: 0020 320a 5241 4e47 452e 2e2e 2e2e 2e2e  . 2.RANGE...
0030: 2e2e 2e2e 2e2e 2e00      
0040:   0020 3330 370a 2d2d 2d2d 2d2d  . 307.--
0050: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  
0060: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  
0070: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  
0080: 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d 2d2d  
0090: 2d2d 2d2d 2d2d 2d2d 2d2d 0a52 4144 4958  --.RADIX
00a0: 202e 2e2e 2e2e 2e2e 2e2e 2e2e 2e2e 2032   . 2
00b0: 0a52 414e 4745 202e 2e2e 2e2e 2e2e 2e2e  .RANGE .
00c0: 2e2e 2e2e 2033 3037 0a    307.

[Bug libfortran/114618] Format produces incorrect output when contains 1x, ok when uses " "

2024-04-13 Thread jvdelisle at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114618

Jerry DeLisle  changed:

   What|Removed |Added

 Status|RESOLVED|REOPENED
 Resolution|DUPLICATE   |---
 Ever confirmed|0   |1
   Last reconfirmed||2024-04-14

--- Comment #4 from Jerry DeLisle  ---
Reopening this. I started working on the 'duplicate' portion of this which is
the 1X vs ' ' portion of it.  Then I realized the first sets of output have a
bunch of garbage in the output. My first thought was the allocatable strings
aspect of this.

I reduced this by removing those aspects of the original post to get the
following.

program tryit
   implicit none
   integer, parameter :: wp = kind(0d0)
   real(kind=wp) :: pi  =
3.14159265358979323846264338327950288419716939937510582097494459230_wp
   character(40) gen1
   character(40) gen2


   gen1 = '(19("."),t1,g0,1x,t21,g0)'
   gen2 = '(19("."),t1,g0," ",t21,g0)'

   write (*, gen1) 'PI', pi
   write (*, gen1) 'REAL(PI)', real(pi)
   write (*, gen1) 'DBLE(PI)', dble(pi)
   write (*, gen1) 'RADIX', radix(pi)
   write (*, gen1) 'RANGE', range(pi)
   write (*, gen1) 'PRECISION', precision(pi)
   write (*,'(80("-"))')
   write (*, gen2) 'PI', pi
   write (*, gen2) 'REAL(PI)', real(pi)
   write (*, gen2) 'DBLE(PI)', dble(pi)
   write (*, gen2) 'RADIX', radix(pi)
   write (*, gen2) 'RANGE', range(pi)
   write (*, gen2) 'PRECISION', precision(pi)
   write (*,'(80("-"))')
end program tryit

Which gives:

$ ./a.out 
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


I will focus on the 1X vs ' ' aspect of this as it fits into the 113897 that I
am currently working.

[Bug libfortran/114618] Format produces incorrect output when contains 1x, ok when uses " "

2024-04-07 Thread jvdelisle at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114618

Jerry DeLisle  changed:

   What|Removed |Added

 Resolution|--- |DUPLICATE
 Status|UNCONFIRMED |RESOLVED

--- Comment #3 from Jerry DeLisle  ---
It is a duplicate of 113897 which I am still workimng on as i get time.

*** This bug has been marked as a duplicate of bug 113897 ***

[Bug libfortran/114618] Format produces incorrect output when contains 1x, ok when uses " "

2024-04-06 Thread jvdelisle at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114618

Jerry DeLisle  changed:

   What|Removed |Added

 CC||jvdelisle at gcc dot gnu.org

--- Comment #2 from Jerry DeLisle  ---
Possibly a dup. I will try to get a closer look later today.

[Bug libfortran/114618] Format produces incorrect output when contains 1x, ok when uses " "

2024-04-06 Thread anlauf at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114618

anlauf at gcc dot gnu.org changed:

   What|Removed |Added

  Component|fortran |libfortran
   See Also||https://gcc.gnu.org/bugzill
   ||a/show_bug.cgi?id=109358

--- Comment #1 from anlauf at gcc dot gnu.org ---
Likely a dup of pr109358.