public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch, libfortran] PR 55539 Regression with -fno-sign-zero
@ 2012-12-15 16:33 Janne Blomqvist
  2012-12-22 22:33 ` Janne Blomqvist
  2012-12-25 19:56 ` Jerry DeLisle
  0 siblings, 2 replies; 3+ messages in thread
From: Janne Blomqvist @ 2012-12-15 16:33 UTC (permalink / raw)
  To: Fortran List, GCC Patches

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

Hello,

the attached patch fixes PR 55539 (4.8 regression). Regtested on
x86_64-unknown-linux-gnu, Ok for trunk?


2012-12-15  Janne Blomqvist  <jb@gcc.gnu.org>

	PR fortran/55539
	* io/write_float.def (output_float): Take into account decimal dot.


testsuite ChangeLog:

2012-12-15  Janne Blomqvist  <jb@gcc.gnu.org>

	PR fortran/55539
	* gfortran.dg/nosigned_zero_3.f90: New testcase.



-- 
Janne Blomqvist

[-- Attachment #2: pr55539.diff --]
[-- Type: application/octet-stream, Size: 1041 bytes --]

diff --git a/libgfortran/io/write_float.def b/libgfortran/io/write_float.def
index 6521f3c..1e30dde 100644
--- a/libgfortran/io/write_float.def
+++ b/libgfortran/io/write_float.def
@@ -483,16 +483,19 @@ output_float (st_parameter_dt *dtp, const fnode *f, char *buffer, size_t size,
   /* Scan the digits string and count the number of zeros.  If we make it
      all the way through the loop, we know the value is zero after the
      rounding completed above.  */
-  for (i = 0; i < ndigits; i++)
+  int hasdot = 0;
+  for (i = 0; i < ndigits + hasdot; i++)
     {
-      if (digits[i] != '0' && digits[i] != '.')
+      if (digits[i] == '.')
+	hasdot = 1;
+      else if (digits[i] != '0')
 	break;
     }
 
   /* To format properly, we need to know if the rounded result is zero and if
      so, we set the zero_flag which may have been already set for
      actual zero.  */
-  if (i == ndigits)
+  if (i == ndigits + hasdot)
     {
       zero_flag = true;
       /* The output is zero, so set the sign according to the sign bit unless

[-- Attachment #3: nosigned_zero_3.f90 --]
[-- Type: application/octet-stream, Size: 359 bytes --]

! { dg-do run }
! { dg-options "-fno-sign-zero" }
!
! PR fortran/55539
!
program nosigned_zero_3
  implicit none
  character(len=20) :: s
  real(4) :: x = -1.2e-3
  real(8) :: y = -1.2e-3
  write(s,'(7f10.3)') x
  if (trim(adjustl(s)) /= "-0.001") call abort
  write(s, '(7f10.3)') y
  if (trim(adjustl(s)) /= "-0.001") call abort
end program nosigned_zero_3

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

* Re: [Patch, libfortran] PR 55539 Regression with -fno-sign-zero
  2012-12-15 16:33 [Patch, libfortran] PR 55539 Regression with -fno-sign-zero Janne Blomqvist
@ 2012-12-22 22:33 ` Janne Blomqvist
  2012-12-25 19:56 ` Jerry DeLisle
  1 sibling, 0 replies; 3+ messages in thread
From: Janne Blomqvist @ 2012-12-22 22:33 UTC (permalink / raw)
  To: Fortran List, GCC Patches

Ping!

On Sat, Dec 15, 2012 at 6:32 PM, Janne Blomqvist
<blomqvist.janne@gmail.com> wrote:
> Hello,
>
> the attached patch fixes PR 55539 (4.8 regression). Regtested on
> x86_64-unknown-linux-gnu, Ok for trunk?
>
>
> 2012-12-15  Janne Blomqvist  <jb@gcc.gnu.org>
>
>         PR fortran/55539
>         * io/write_float.def (output_float): Take into account decimal dot.
>
>
> testsuite ChangeLog:
>
> 2012-12-15  Janne Blomqvist  <jb@gcc.gnu.org>
>
>         PR fortran/55539
>         * gfortran.dg/nosigned_zero_3.f90: New testcase.
>
>
>
> --
> Janne Blomqvist



-- 
Janne Blomqvist

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

* Re: [Patch, libfortran] PR 55539 Regression with -fno-sign-zero
  2012-12-15 16:33 [Patch, libfortran] PR 55539 Regression with -fno-sign-zero Janne Blomqvist
  2012-12-22 22:33 ` Janne Blomqvist
@ 2012-12-25 19:56 ` Jerry DeLisle
  1 sibling, 0 replies; 3+ messages in thread
From: Jerry DeLisle @ 2012-12-25 19:56 UTC (permalink / raw)
  To: Janne Blomqvist; +Cc: Fortran List, GCC Patches

On 12/15/2012 08:32 AM, Janne Blomqvist wrote:
> Hello,
>
> the attached patch fixes PR 55539 (4.8 regression). Regtested on
> x86_64-unknown-linux-gnu, Ok for trunk?
>
>
> 2012-12-15  Janne Blomqvist  <jb@gcc.gnu.org>
>
> 	PR fortran/55539
> 	* io/write_float.def (output_float): Take into account decimal dot.
>
>
> testsuite ChangeLog:
>
> 2012-12-15  Janne Blomqvist  <jb@gcc.gnu.org>
>
> 	PR fortran/55539
> 	* gfortran.dg/nosigned_zero_3.f90: New testcase.
>

OK, thanks for patch.

Jerry

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

end of thread, other threads:[~2012-12-25 19:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-15 16:33 [Patch, libfortran] PR 55539 Regression with -fno-sign-zero Janne Blomqvist
2012-12-22 22:33 ` Janne Blomqvist
2012-12-25 19:56 ` Jerry DeLisle

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).