[patch, libgfortran] Bug 57822 - I/O: "(g0)" wrongly prints "E+0000"

Jerry DeLisle jvdelisle@charter.net
Mon Feb 9 01:10:00 GMT 2015


The attached patch fixes this by checking for the case when we are doing g0 
editing and the exponent is 0.

Regression tested on X86-64.  For the larger kinds, we are on a different code 
path out of necessity, so we need to address this corner case.

I will commit in a day or two as simple/obvious, with a Changelog for the 
testsuite as well.

Regards,

Jerry

2015-02-09  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/57822
	* io/write_float.def (output_float): If doing g0 editing and
	exponent is zero, do not emit exponent.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr57822.diff
Type: text/x-patch
Size: 332 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20150209/49204473/attachment.bin>
-------------- next part --------------
! { dg-do run }
! PR58722
program testit
  character(50) :: astring
  
  write(astring, '(g0)') 0.1_4
  if (test(astring)) call abort
  write(astring, '(g0)') 0.1_8
  if (test(astring)) call abort
  write(astring, '(g0)') 0.1_10
  if (test(astring)) call abort
  write(astring, '(g0)') 0.1_16
  if (test(astring)) call abort

contains

function test (string1) result(res)
  character(len=*) :: string1
  logical :: res

  res = .true.
  do i = 1, len(string1)
    if (string1(i:i) == 'E') return
  end do
  res = .false.
end function

end program


More information about the Gcc-patches mailing list