public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch, libgfortran] PR117820
@ 2024-12-03  4:13 Jerry D
  2024-12-03  6:51 ` Paul Richard Thomas
  2024-12-03 18:08 ` Harald Anlauf
  0 siblings, 2 replies; 4+ messages in thread
From: Jerry D @ 2024-12-03  4:13 UTC (permalink / raw)
  To: gfortran; +Cc: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 518 bytes --]

Hi all,

Attached patch adds a test for zero that is needed for write_boz to work 
correctly. Almost obvious.

Regression tested on x86_64.

Ok for trunk?

Jerry

Author: Jerry DeLisle <jvdelisle@gcc.gnu.org>
Date:   Mon Dec 2 19:45:26 2024 -0800

     Fortran: Fix B64.0 formatted write output.

             PR fortran/117820

     libgfortran/ChangeLog:

             * io/write.c (write_b): Add test for zero needed by write_boz.

     gcc/testsuite/ChangeLog:

             * gfortran.dg/pr117820.f90: New test.


[-- Attachment #2: pr117820.diff --]
[-- Type: text/x-patch, Size: 1105 bytes --]

diff --git a/gcc/testsuite/gfortran.dg/pr117820.f90 b/gcc/testsuite/gfortran.dg/pr117820.f90
new file mode 100644
index 00000000000..e873393f2ef
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr117820.f90
@@ -0,0 +1,12 @@
+! { dg-do run }
+! { dg-options "-std=gnu" }
+! see pr117820, -std=gnu for this test needed to avoid a warning with -pedantic
+! on line 9 below.
+program test
+  integer(8) :: x
+  character(80) :: output
+  output = "garbage"
+  x = -huge(x) - 1_8
+  write(output, '("<",B64.0,">")') x
+  if (output .ne. "<1000000000000000000000000000000000000000000000000000000000000000>") stop 1
+end program
diff --git a/libgfortran/io/write.c b/libgfortran/io/write.c
index 2f414c6b57d..ccb2b5cb810 100644
--- a/libgfortran/io/write.c
+++ b/libgfortran/io/write.c
@@ -1392,6 +1392,10 @@ write_b (st_parameter_dt *dtp, const fnode *f, const char *source, int len)
     {
       n = extract_uint (source, len);
       p = btoa (n, itoa_buf, sizeof (itoa_buf));
+
+      /* Test for zero. Needed by write_boz.  */
+      if (n != 0)
+       n = 1;
       write_boz (dtp, f, p, n, len);
     }
 }

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch, libgfortran] PR117820
  2024-12-03  4:13 [patch, libgfortran] PR117820 Jerry D
@ 2024-12-03  6:51 ` Paul Richard Thomas
  2024-12-03 18:08 ` Harald Anlauf
  1 sibling, 0 replies; 4+ messages in thread
From: Paul Richard Thomas @ 2024-12-03  6:51 UTC (permalink / raw)
  To: Jerry D; +Cc: gfortran, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 845 bytes --]

Hi Jerry,

That's fine for trunk and, after a decent interval, I would suggest that
you backport to 14-branch.

Please add the name of the contributor to the testcase unless you have been
asked not to.

Thanks

Paul


On Tue, 3 Dec 2024 at 04:13, Jerry D <jvdelisle2@gmail.com> wrote:

> Hi all,
>
> Attached patch adds a test for zero that is needed for write_boz to work
> correctly. Almost obvious.
>
> Regression tested on x86_64.
>
> Ok for trunk?
>
> Jerry
>
> Author: Jerry DeLisle <jvdelisle@gcc.gnu.org>
> Date:   Mon Dec 2 19:45:26 2024 -0800
>
>      Fortran: Fix B64.0 formatted write output.
>
>              PR fortran/117820
>
>      libgfortran/ChangeLog:
>
>              * io/write.c (write_b): Add test for zero needed by write_boz.
>
>      gcc/testsuite/ChangeLog:
>
>              * gfortran.dg/pr117820.f90: New test.
>
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch, libgfortran] PR117820
  2024-12-03  4:13 [patch, libgfortran] PR117820 Jerry D
  2024-12-03  6:51 ` Paul Richard Thomas
@ 2024-12-03 18:08 ` Harald Anlauf
  2024-12-03 18:08   ` Harald Anlauf
  1 sibling, 1 reply; 4+ messages in thread
From: Harald Anlauf @ 2024-12-03 18:08 UTC (permalink / raw)
  To: Jerry D, gfortran; +Cc: gcc-patches

Hi Jerry,

regarding the testcase, these variants are both standard-conforming and
silent under -pedantic:

   x = ibset (0_8, 63)
   x = ibset (0_8, bit_size(x)-1)

No trickery needed.

Cheers,
Harald

Am 03.12.24 um 05:13 schrieb Jerry D:
> Hi all,
>
> Attached patch adds a test for zero that is needed for write_boz to work
> correctly. Almost obvious.
>
> Regression tested on x86_64.
>
> Ok for trunk?
>
> Jerry
>
> Author: Jerry DeLisle <jvdelisle@gcc.gnu.org>
> Date:   Mon Dec 2 19:45:26 2024 -0800
>
>      Fortran: Fix B64.0 formatted write output.
>
>              PR fortran/117820
>
>      libgfortran/ChangeLog:
>
>              * io/write.c (write_b): Add test for zero needed by write_boz.
>
>      gcc/testsuite/ChangeLog:
>
>              * gfortran.dg/pr117820.f90: New test.
>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch, libgfortran] PR117820
  2024-12-03 18:08 ` Harald Anlauf
@ 2024-12-03 18:08   ` Harald Anlauf
  0 siblings, 0 replies; 4+ messages in thread
From: Harald Anlauf @ 2024-12-03 18:08 UTC (permalink / raw)
  To: gcc-patches; +Cc: fortran

Hi Jerry,

regarding the testcase, these variants are both standard-conforming and
silent under -pedantic:

   x = ibset (0_8, 63)
   x = ibset (0_8, bit_size(x)-1)

No trickery needed.

Cheers,
Harald

Am 03.12.24 um 05:13 schrieb Jerry D:
> Hi all,
> 
> Attached patch adds a test for zero that is needed for write_boz to work 
> correctly. Almost obvious.
> 
> Regression tested on x86_64.
> 
> Ok for trunk?
> 
> Jerry
> 
> Author: Jerry DeLisle <jvdelisle@gcc.gnu.org>
> Date:   Mon Dec 2 19:45:26 2024 -0800
> 
>      Fortran: Fix B64.0 formatted write output.
> 
>              PR fortran/117820
> 
>      libgfortran/ChangeLog:
> 
>              * io/write.c (write_b): Add test for zero needed by write_boz.
> 
>      gcc/testsuite/ChangeLog:
> 
>              * gfortran.dg/pr117820.f90: New test.
> 



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-12-03 18:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-12-03  4:13 [patch, libgfortran] PR117820 Jerry D
2024-12-03  6:51 ` Paul Richard Thomas
2024-12-03 18:08 ` Harald Anlauf
2024-12-03 18:08   ` Harald Anlauf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).