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 <jvdeli...@gcc.gnu.org>
PR libgfortran/57822
* io/write_float.def (output_float): If doing g0 editing and
exponent is zero, do not emit exponent.
Index: write_float.def
===================================================================
--- write_float.def (revision 220505)
+++ write_float.def (working copy)
@@ -724,7 +724,7 @@
}
/* Output the exponent. */
- if (expchar)
+ if (expchar && !(dtp->u.p.g0_no_blanks && e == 0))
{
if (expchar != ' ')
{
! { 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