Bug 37863 - [4.3/4.4 Regression] Display of a value close but less to 1 shows 2 with '(F3.0)'
Summary: [4.3/4.4 Regression] Display of a value close but less to 1 shows 2 with '(F3...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.3.2
: P4 normal
Target Milestone: 4.3.3
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2008-10-17 15:16 UTC by Sylvestre Ledru
Modified: 2008-10-19 15:43 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2008-10-17 15:42:22


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sylvestre Ledru 2008-10-17 15:16:55 UTC
With the code here:
----
      program pb
      character*10 form
      character*4093 str
      str=' '
      write(form,120) 3,0
      write(str(1:3),form) 1.0d0 - 1.110223024625157D-16
      print *,str(1:10)
 120  format('(f',i2,'.',i2,')')
      end
----

Compiled with gfortran 4.3.2:
the output is 2

With the gfortran 4.2.4
the result is 1 (which is the right one)

$ gfortran-4.3 -o pb pb.f && ./pb 
  2.       
$ gfortran-4.2 -o pb pb.f && ./pb 
  1.
Comment 1 Daniel Kraft 2008-10-17 15:42:22 UTC
Confirmed on trunk, with this test:

program pb
  write(*,'(F3.0)') 1.0d0 - 1.110223024625157D-16
end

Changing decimals display to a value larger than 0 outputs 1 correctly.
Comment 2 Tobias Burnus 2008-10-17 15:50:50 UTC
Jerry, do you have an idea?
Comment 3 Jerry DeLisle 2008-10-17 19:32:16 UTC
I will try to look at this tonight.
Comment 4 Jerry DeLisle 2008-10-18 05:28:46 UTC
Subject: Bug 37863

Author: jvdelisle
Date: Sat Oct 18 05:27:23 2008
New Revision: 141208

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=141208
Log:
	Fix ChangeLog
2008-10-17  Jerry DeLisle  <jvdelisle@gcc.gnu.org

	PR libfortran/37863
	* io/write_float.def (WRITE_FLOAT): Round to 1.0 correctly.
	* io/io.h (st_parameter_44): Fix id type declaration.

Modified:
    trunk/libgfortran/ChangeLog

Comment 5 Jerry DeLisle 2008-10-18 05:32:23 UTC
Fixed on trunk. I accidentally committed the patch with the wrong PR number in the Changelog (37707)

This I will backport to 4.3 in a day.
Comment 6 Sylvestre Ledru 2008-10-18 10:46:13 UTC
I must say that I am very impressed by your reactivity!
Thanks!
Comment 7 Jerry DeLisle 2008-10-19 15:29:51 UTC
Subject: Bug 37863

Author: jvdelisle
Date: Sun Oct 19 15:28:25 2008
New Revision: 141227

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=141227
Log:
2008-10-19  Jerry DeLisle  <jvdelisle@gcc.gnu.org

	PR libfortran/37863
	Backport from trunk.
	* io/write_float.def (WRITE_FLOAT): Round to 1.0 correctly.

2008-10-19  Jerry DeLisle  <jvdelisle@gcc.gnu.org

	PR libfortran/37707
	Backport from trunk.
	* io/list_read.c (nml_get_obj_data): If the first namelist object rank
	is greater than zero, call nml_object_read with the first object rather
	than the sub-object.

Modified:
    branches/gcc-4_3-branch/libgfortran/ChangeLog
    branches/gcc-4_3-branch/libgfortran/io/list_read.c
    branches/gcc-4_3-branch/libgfortran/io/write_float.def

Comment 8 Jerry DeLisle 2008-10-19 15:43:33 UTC
Fixed on 4.3 and 4.4