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

--- Comment #7 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
The root of the problem here is that the function write_boz uses a type int to
pass in the value n, this value is then tested for zero which fails for a 64
bit integer.

The following hack makes it work but I don't like this fix.

diff --git a/libgfortran/io/write.c b/libgfortran/io/write.c
index 2f414c6b57d..378013dbd18 100644
--- a/libgfortran/io/write.c
+++ b/libgfortran/io/write.c
@@ -1392,6 +1392,8 @@ 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));
+      if (n != 0)
+       n = 1;
       write_boz (dtp, f, p, n, len);

For larger integers, the test for zero is done in the big_btoa functions where
the unsigned value is known and it can be explicitly tested. the variable n in
write_boz really ought to be a bool so that it is more obvious to maintainers
what is going on.

I will clean this up and submit a patch for approval.

Reply via email to