* [patch, libgfortran] PR47434 Wrong field width for NaN with (F0.n) formatting
@ 2011-01-29 0:29 Jerry DeLisle
2011-01-29 17:31 ` Jack Howarth
2011-01-29 17:56 ` Tobias Burnus
0 siblings, 2 replies; 9+ messages in thread
From: Jerry DeLisle @ 2011-01-29 0:29 UTC (permalink / raw)
To: gfortran; +Cc: gcc patches
[-- Attachment #1: Type: text/plain, Size: 1106 bytes --]
Hi,
The attached patches fix more than a few issues with Nan and Infinites related
to field widths and showing signs or not showing signs.
Previously we took the approach to show '+' on infinity to be consistent with
'-'. However in the case of f0.n formatting, this does not provide the minimum
possible width. The patch changes that behaviour. This results in quite a few
testsuite adjustments.
Another issue is the write_infnan function did not take into account the new
sign modes s, ss, and sp. We have this feature elsewhere and I used the
calculate_sign function to adjust the widths and determine whether or not to
emit signs, inf or infinity, and nan.
The program pr47434.f90 is not dejagnu-ized, but I used this to observe what we
are doing here. It mist be compiled with -fno-range-check. (We now closely
match intel on this)
Regression tested. OK for trunk?
Jerry
2011-01-28 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libgfortran/47434
* io/write_float.def (write_infnan): Use calculate_sign to determine
if the sign should be given and check field widths accordingly.
[-- Attachment #2: pr47434.diff --]
[-- Type: text/x-patch, Size: 2668 bytes --]
Index: write_float.def
===================================================================
--- write_float.def (revision 169322)
+++ write_float.def (working copy)
@@ -660,15 +660,26 @@ write_infnan (st_parameter_dt *dtp, const fnode *f
{
char * p, fin;
int nb = 0;
+ sign_t sign;
+ int mark;
if (f->format != FMT_B && f->format != FMT_O && f->format != FMT_Z)
{
+ sign = calculate_sign (dtp, sign_bit);
+ mark = (sign == S_PLUS || sign == S_MINUS) ? 8 : 7;
+
nb = f->u.real.w;
/* If the field width is zero, the processor must select a width
not zero. 4 is chosen to allow output of '-Inf' or '+Inf' */
- if (nb == 0) nb = 4;
+ if (nb == 0)
+ {
+ if (isnan_flag)
+ nb = 3;
+ else
+ nb = (sign == S_PLUS || sign == S_MINUS) ? 4 : 3;
+ }
p = write_block (dtp, nb);
if (p == NULL)
return;
@@ -720,24 +731,28 @@ write_infnan (st_parameter_dt *dtp, const fnode *f
if (unlikely (is_char4_unit (dtp)))
{
gfc_char4_t *p4 = (gfc_char4_t *) p;
- if (nb > 8)
+
+ if (nb > mark)
/* We have room, so output 'Infinity' */
memcpy4 (p4 + nb - 8, "Infinity", 8);
else
- /* For the case of width equals 8, there is not enough room
+ /* For the case of width equals mark, there is not enough room
for the sign and 'Infinity' so we go with 'Inf' */
memcpy4 (p4 + nb - 3, "Inf", 3);
- if (nb < 9 && nb > 3)
- /* Put the sign in front of Inf */
- p4[nb - 4] = (gfc_char4_t) fin;
- else if (nb > 8)
- /* Put the sign in front of Infinity */
- p4[nb - 9] = (gfc_char4_t) fin;
+ if (sign == S_PLUS || sign == S_MINUS)
+ {
+ if (nb < 9 && nb > 3)
+ /* Put the sign in front of Inf */
+ p4[nb - 4] = (gfc_char4_t) fin;
+ else if (nb > 8)
+ /* Put the sign in front of Infinity */
+ p4[nb - 9] = (gfc_char4_t) fin;
+ }
return;
}
- if (nb > 8)
+ if (nb > mark)
/* We have room, so output 'Infinity' */
memcpy(p + nb - 8, "Infinity", 8);
else
@@ -745,10 +760,13 @@ write_infnan (st_parameter_dt *dtp, const fnode *f
for the sign and 'Infinity' so we go with 'Inf' */
memcpy(p + nb - 3, "Inf", 3);
- if (nb < 9 && nb > 3)
- p[nb - 4] = fin; /* Put the sign in front of Inf */
- else if (nb > 8)
- p[nb - 9] = fin; /* Put the sign in front of Infinity */
+ if (sign == S_PLUS || sign == S_MINUS)
+ {
+ if (nb < 9 && nb > 3)
+ p[nb - 4] = fin; /* Put the sign in front of Inf */
+ else if (nb > 8)
+ p[nb - 9] = fin; /* Put the sign in front of Infinity */
+ }
}
else
{
[-- Attachment #3: test.diff --]
[-- Type: text/x-patch, Size: 6475 bytes --]
Index: gfortran.dg/read_infnan_1.f90
===================================================================
--- gfortran.dg/read_infnan_1.f90 (revision 169374)
+++ gfortran.dg/read_infnan_1.f90 (working copy)
@@ -22,9 +22,9 @@ read(10,'(7f10.3)') x4
rewind(10)
read(10,'(7f10.3)') x8
write (output, '("x4 =",7G6.0)') x4
-if (output.ne."x4 = +Inf NaN +Inf NaN -Inf NaN +Inf") call abort
+if (output.ne."x4 = Inf NaN Inf NaN -Inf NaN Inf") call abort
write (output, '("x8 =",7G6.0)') x8
-if (output.ne."x8 = +Inf NaN +Inf NaN -Inf NaN +Inf") call abort
+if (output.ne."x8 = Inf NaN Inf NaN -Inf NaN Inf") call abort
!print '("x4 =",7G6.0)', x4
!print '("x8 =",7G6.0)', x8
end program pr43298
Index: gfortran.dg/module_nan.f90
===================================================================
--- gfortran.dg/module_nan.f90 (revision 169374)
+++ gfortran.dg/module_nan.f90 (working copy)
@@ -19,7 +19,7 @@ program a
if (log(abs(inf)) < huge(inf)) call abort()
if (log(abs(minf)) < huge(inf)) call abort()
if (.not. isnan(nan)) call abort()
- write(str,*) inf
+ write(str,"(sp,f10.2)") inf
if (adjustl(str) /= "+Infinity") call abort()
write(str,*) minf
if (adjustl(str) /= "-Infinity") call abort()
Index: gfortran.dg/char4_iunit_1.f03
===================================================================
--- gfortran.dg/char4_iunit_1.f03 (revision 169374)
+++ gfortran.dg/char4_iunit_1.f03 (working copy)
@@ -26,9 +26,9 @@ program char4_iunit_1
write(string, *) 1.2345e-06, 4.2846e+10_8
if (string .ne. 4_" 1.23450002E-06 42846000000.000000 ") call abort
write(string, *) nan, inf
- if (string .ne. 4_" NaN +Infinity ") call abort
+ if (string .ne. 4_" NaN Infinity ") call abort
write(string, '(10x,f3.1,3x,f9.1)') nan, inf
- if (string .ne. 4_" NaN +Infinity ") call abort
+ if (string .ne. 4_" NaN Infinity ") call abort
write(string, *) (1.2, 3.4 )
if (string .ne. 4_" ( 1.2000000 , 3.4000001 ) ") call abort
end program char4_iunit_1
Index: gfortran.dg/large_real_kind_1.f90
===================================================================
--- gfortran.dg/large_real_kind_1.f90 (revision 169374)
+++ gfortran.dg/large_real_kind_1.f90 (working copy)
@@ -56,7 +56,7 @@ program test
call testoutput (-7.51e-100_k,-7.51e-100_8,15,'(F15.10)')
x = huge(x)
- call outputstring (2*x,'(F20.15)',' +Infinity')
+ call outputstring (2*x,'(F20.15)',' Infinity')
call outputstring (-2*x,'(F20.15)',' -Infinity')
write (c1,'(G20.10E5)') x
Index: gfortran.dg/nan_7.f90
===================================================================
--- gfortran.dg/nan_7.f90 (revision 0)
+++ gfortran.dg/nan_7.f90 (revision 0)
@@ -0,0 +1,14 @@
+! { dg-do run }
+! PR47293 NAN not correctly read
+character(len=200) :: str
+real(16) :: r, x, y, z
+integer(16) :: k1, k2
+x = 0.0
+y = 0.0
+r = 1.0
+str = 'NAN' ; read(str,*) r
+z = x/y
+k1 = transfer(z,k1)
+k2 = transfer(r,k2)
+if (k1.ne.k2) call abort
+end
Index: gfortran.dg/real_const_3.f90
===================================================================
--- gfortran.dg/real_const_3.f90 (revision 169374)
+++ gfortran.dg/real_const_3.f90 (working copy)
@@ -16,7 +16,7 @@ program main
b = 1/exp(1000.0)
write(str,*) a
- if (trim(adjustl(str)) .ne. '+Infinity') call abort
+ if (trim(adjustl(str)) .ne. 'Infinity') call abort
if (b .ne. 0.) call abort
@@ -36,7 +36,7 @@ program main
if (trim(adjustl(str)) .ne. '-Infinity') call abort
write(str,*) 3.0/0.
- if (trim(adjustl(str)) .ne. '+Infinity') call abort
+ if (trim(adjustl(str)) .ne. 'Infinity') call abort
write(str,*) nan
if (trim(adjustl(str)) .ne. 'NaN') call abort
@@ -48,7 +48,7 @@ program main
if (trim(adjustl(str)) .ne. '( NaN, NaN)') call abort
write(str,*) z3
- if (trim(adjustl(str)) .ne. '( +Infinity, -Infinity)') call abort
+ if (trim(adjustl(str)) .ne. '( Infinity, -Infinity)') call abort
write(str,*) z4
if (trim(adjustl(str)) .ne. '( 0.0000000 , -0.0000000 )') call abort
Index: gfortran.fortran-torture/execute/nan_inf_fmt.f90
===================================================================
--- gfortran.fortran-torture/execute/nan_inf_fmt.f90 (revision 169374)
+++ gfortran.fortran-torture/execute/nan_inf_fmt.f90 (working copy)
@@ -1,4 +1,5 @@
!pr 12839- F2003 formatting of Inf /Nan
+! Modified for PR47434
implicit none
character*40 l
character*12 fmt
@@ -15,11 +16,11 @@
! check a field width = 0
fmt = '(F0.0)'
write(l,fmt=fmt)pos_inf
- if (l.ne.'+Inf') call abort
+ if (l.ne.'Inf') call abort
write(l,fmt=fmt)neg_inf
if (l.ne.'-Inf') call abort
write(l,fmt=fmt)nan
- if (l.ne.' NaN') call abort
+ if (l.ne.'NaN') call abort
! check a field width < 3
fmt = '(F2.0)'
@@ -42,7 +43,7 @@
! check a field width > 3
fmt = '(F4.0)'
write(l,fmt=fmt)pos_inf
- if (l.ne.'+Inf') call abort
+ if (l.ne.' Inf') call abort
write(l,fmt=fmt)neg_inf
if (l.ne.'-Inf') call abort
write(l,fmt=fmt)nan
@@ -51,7 +52,7 @@
! check a field width = 7
fmt = '(F7.0)'
write(l,fmt=fmt)pos_inf
- if (l.ne.' +Inf') call abort
+ if (l.ne.' Inf') call abort
write(l,fmt=fmt)neg_inf
if (l.ne.' -Inf') call abort
write(l,fmt=fmt)nan
@@ -60,7 +61,7 @@
! check a field width = 8
fmt = '(F8.0)'
write(l,fmt=fmt)pos_inf
- if (l.ne.' +Inf') call abort
+ if (l.ne.'Infinity') call abort
write(l,fmt=fmt)neg_inf
if (l.ne.' -Inf') call abort
write(l,fmt=fmt)nan
@@ -69,7 +70,7 @@
! check a field width = 9
fmt = '(F9.0)'
write(l,fmt=fmt)pos_inf
- if (l.ne.'+Infinity') call abort
+ if (l.ne.' Infinity') call abort
write(l,fmt=fmt)neg_inf
if (l.ne.'-Infinity') call abort
write(l,fmt=fmt)nan
@@ -78,7 +79,7 @@
! check a field width = 14
fmt = '(F14.0)'
write(l,fmt=fmt)pos_inf
- if (l.ne.' +Infinity') call abort
+ if (l.ne.' Infinity') call abort
write(l,fmt=fmt)neg_inf
if (l.ne.' -Infinity') call abort
write(l,fmt=fmt)nan
[-- Attachment #4: pr47434.f90 --]
[-- Type: text/x-fortran, Size: 2188 bytes --]
module nonordinal
implicit none
real, parameter :: inf = 1./0., nan = 0./0., minf = -1./0.0
end module nonordinal
program testnan
use nonordinal
implicit none
character(kind=4,len=20) :: str
print "(F0.2)", nan
print "(F3.2)", nan
print "(sp,F0.2)", inf ! SIGN=PLUS
print "(ss,F0.2)", inf ! SIGN=SUPPRESS
print "(s, F0.2)", inf ! SIGN=PROCESSOR_DEFINED
print "(sp,F1.2)", inf ! SIGN=PLUS
print "(ss,F1.2)", inf ! SIGN=SUPPRESS
print "(s, F1.2)", inf ! SIGN=PROCESSOR_DEFINED
print "(sp,F2.2)", inf ! SIGN=PLUS
print "(ss,F2.2)", inf ! SIGN=SUPPRESS
print "(s, F2.2)", inf ! SIGN=PROCESSOR_DEFINED
print "(sp,F3.2)", inf ! SIGN=PLUS
print "(ss,F3.2)", inf ! SIGN=SUPPRESS
print "(s, F3.2)", inf ! SIGN=PROCESSOR_DEFINED
print "(sp,F4.2)", inf ! SIGN=PLUS
print "(ss,F4.2)", inf ! SIGN=SUPPRESS
print "(s, F4.2)", inf ! SIGN=PROCESSOR_DEFINED
print "(sp,F5.2)", inf ! SIGN=PLUS
print "(ss,F5.2)", inf ! SIGN=SUPPRESS
print "(s, F5.2)", inf ! SIGN=PROCESSOR_DEFINED
print "(sp,F6.2)", inf ! SIGN=PLUS
print "(ss,F6.2)", inf ! SIGN=SUPPRESS
print "(s, F6.2)", inf ! SIGN=PROCESSOR_DEFINED
print "(sp,F7.2)", inf ! SIGN=PLUS
print "(ss,F7.2)", inf ! SIGN=SUPPRESS
print "(s, F7.2)", inf ! SIGN=PROCESSOR_DEFINED
print "(sp,F8.2)", inf ! SIGN=PLUS
print "(ss,F8.2)", inf ! SIGN=SUPPRESS
print "(s, F8.2)", inf ! SIGN=PROCESSOR_DEFINED
print "(sp,F9.2)", inf ! SIGN=PLUS
print "(ss,F9.2)", inf ! SIGN=SUPPRESS
print "(s, F9.2)", inf ! SIGN=PROCESSOR_DEFINED
print "(sp,F10.2)", inf ! SIGN=PLUS
print "(ss,F10.2)", inf ! SIGN=SUPPRESS
print "(s, F10.2)", inf ! SIGN=PROCESSOR_DEFINED
print "(sp,F11.2)", inf ! SIGN=PLUS
print "(ss,F11.2)", inf ! SIGN=SUPPRESS
print "(s, F11.2)", inf ! SIGN=PROCESSOR_DEFINED
if (log(abs(inf)) < huge(inf)) print *, 49
if (log(abs(minf)) < huge(inf)) print *, 50
if (.not. isnan(nan)) print *, 51
write(str,"(sp,f10.2)") inf
if (adjustl(str) /= 4_"+Infinity") print *, 53, str
write(str,*) minf
if (adjustl(str) /= 4_"-Infinity") print *, 55
write(str,*) nan
if (adjustl(str) /= 4_"NaN") print *, 57
end program testnan
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch, libgfortran] PR47434 Wrong field width for NaN with (F0.n) formatting
2011-01-29 0:29 [patch, libgfortran] PR47434 Wrong field width for NaN with (F0.n) formatting Jerry DeLisle
@ 2011-01-29 17:31 ` Jack Howarth
2011-01-29 18:44 ` Jerry DeLisle
2011-01-29 17:56 ` Tobias Burnus
1 sibling, 1 reply; 9+ messages in thread
From: Jack Howarth @ 2011-01-29 17:31 UTC (permalink / raw)
To: Jerry DeLisle; +Cc: gfortran, gcc patches
On Fri, Jan 28, 2011 at 02:55:24PM -0800, Jerry DeLisle wrote:
> Hi,
>
> The attached patches fix more than a few issues with Nan and Infinites
> related to field widths and showing signs or not showing signs.
>
> Previously we took the approach to show '+' on infinity to be consistent
> with '-'. However in the case of f0.n formatting, this does not provide
> the minimum possible width. The patch changes that behaviour. This
> results in quite a few testsuite adjustments.
>
> Another issue is the write_infnan function did not take into account the
> new sign modes s, ss, and sp. We have this feature elsewhere and I used
> the calculate_sign function to adjust the widths and determine whether or
> not to emit signs, inf or infinity, and nan.
>
> The program pr47434.f90 is not dejagnu-ized, but I used this to observe
> what we are doing here. It mist be compiled with -fno-range-check. (We
> now closely match intel on this)
>
> Regression tested. OK for trunk?
Jerry,
This patch causes the regressions...
FAIL: gfortran.dg/nan_7.f90 -O0 (test for excess errors)
WARNING: gfortran.dg/nan_7.f90 -O0 compilation failed to produce executable
FAIL: gfortran.dg/nan_7.f90 -O1 (test for excess errors)
WARNING: gfortran.dg/nan_7.f90 -O1 compilation failed to produce executable
FAIL: gfortran.dg/nan_7.f90 -O2 (test for excess errors)
WARNING: gfortran.dg/nan_7.f90 -O2 compilation failed to produce executable
FAIL: gfortran.dg/nan_7.f90 -O3 -fomit-frame-pointer (test for excess errors)
WARNING: gfortran.dg/nan_7.f90 -O3 -fomit-frame-pointer compilation failed to produce executable
FAIL: gfortran.dg/nan_7.f90 -O3 -fomit-frame-pointer -funroll-loops (test for excess errors)
WARNING: gfortran.dg/nan_7.f90 -O3 -fomit-frame-pointer -funroll-loops compilation failed to produce executable
FAIL: gfortran.dg/nan_7.f90 -O3 -fomit-frame-pointer -funroll-all-loops -finline-functions (test for excess errors)
WARNING: gfortran.dg/nan_7.f90 -O3 -fomit-frame-pointer -funroll-all-loops -finline-functions compilation failed to produce executable
FAIL: gfortran.dg/nan_7.f90 -O3 -g (test for excess errors)
WARNING: gfortran.dg/nan_7.f90 -O3 -g compilation failed to produce executable
FAIL: gfortran.dg/nan_7.f90 -Os (test for excess errors)
WARNING: gfortran.dg/nan_7.f90 -Os compilation failed to produce executable
at -m32 and -m64 on x86_64-apple-darwin10. The failures are of the form...
/sw/src/fink.build/gcc46-4.6.0-1000/darwin_objdir/gcc/testsuite/gfortran/../../gfortran -B/sw/src/fink.build/gcc46-4.6.0-1000/darwin_objdir/gcc/testsuite/gfortran/../../ -B/sw/src/fink.build/gcc46-4.6.0-1000/darwin_objdir/x86_64-apple-darwin10.7.0/i386/libgfortran/ /sw/src/fink.build/gcc46-4.6.0-1000/gcc-4.6-20110128/gcc/testsuite/gfortran.dg/nan_7.f90 -O0 -pedantic-errors -B/sw/src/fink.build/gcc46-4.6.0-1000/darwin_objdir/x86_64-apple-darwin10.7.0/i386/libgfortran/.libs -L/sw/src/fink.build/gcc46-4.6.0-1000/darwin_objdir/x86_64-apple-darwin10.7.0/i386/libgfortran/.libs -L/sw/src/fink.build/gcc46-4.6.0-1000/darwin_objdir/x86_64-apple-darwin10.7.0/i386/libgfortran/.libs -B/sw/src/fink.build/gcc46-4.6.0-1000/darwin_objdir/x86_64-apple-darwin10.7.0/i386/libquadmath/.libs -L/sw/src/fink.build/gcc46-4.6.0-1000/darwin_objdir/x86_64-apple-darwin10.7.0/i386/libquadmath/.libs -L/sw/src/fink.build/gcc46-4.6.0-1000/darwin_objdir/x86_64-apple-darwin10.7.0/i386/libquadmath/.libs -L/sw/src/fink.build/gcc46-4.6.0-1000/darwin_objdir/x86_64-apple-darwin10.7.0/i386/libiberty -lm -m32 -o ./nan_7.exe
/sw/src/fink.build/gcc46-4.6.0-1000/gcc-4.6-20110128/gcc/testsuite/gfortran.dg/nan_7.f90:5.10:
integer(16) :: k1, k2
1
Error: Kind 16 not supported for type INTEGER at (1)
Jack
>
> Jerry
>
> 2011-01-28 Jerry DeLisle <jvdelisle@gcc.gnu.org>
>
> PR libgfortran/47434
> * io/write_float.def (write_infnan): Use calculate_sign to determine
> if the sign should be given and check field widths accordingly.
> Index: write_float.def
> ===================================================================
> --- write_float.def (revision 169322)
> +++ write_float.def (working copy)
> @@ -660,15 +660,26 @@ write_infnan (st_parameter_dt *dtp, const fnode *f
> {
> char * p, fin;
> int nb = 0;
> + sign_t sign;
> + int mark;
>
> if (f->format != FMT_B && f->format != FMT_O && f->format != FMT_Z)
> {
> + sign = calculate_sign (dtp, sign_bit);
> + mark = (sign == S_PLUS || sign == S_MINUS) ? 8 : 7;
> +
> nb = f->u.real.w;
>
> /* If the field width is zero, the processor must select a width
> not zero. 4 is chosen to allow output of '-Inf' or '+Inf' */
>
> - if (nb == 0) nb = 4;
> + if (nb == 0)
> + {
> + if (isnan_flag)
> + nb = 3;
> + else
> + nb = (sign == S_PLUS || sign == S_MINUS) ? 4 : 3;
> + }
> p = write_block (dtp, nb);
> if (p == NULL)
> return;
> @@ -720,24 +731,28 @@ write_infnan (st_parameter_dt *dtp, const fnode *f
> if (unlikely (is_char4_unit (dtp)))
> {
> gfc_char4_t *p4 = (gfc_char4_t *) p;
> - if (nb > 8)
> +
> + if (nb > mark)
> /* We have room, so output 'Infinity' */
> memcpy4 (p4 + nb - 8, "Infinity", 8);
> else
> - /* For the case of width equals 8, there is not enough room
> + /* For the case of width equals mark, there is not enough room
> for the sign and 'Infinity' so we go with 'Inf' */
> memcpy4 (p4 + nb - 3, "Inf", 3);
>
> - if (nb < 9 && nb > 3)
> - /* Put the sign in front of Inf */
> - p4[nb - 4] = (gfc_char4_t) fin;
> - else if (nb > 8)
> - /* Put the sign in front of Infinity */
> - p4[nb - 9] = (gfc_char4_t) fin;
> + if (sign == S_PLUS || sign == S_MINUS)
> + {
> + if (nb < 9 && nb > 3)
> + /* Put the sign in front of Inf */
> + p4[nb - 4] = (gfc_char4_t) fin;
> + else if (nb > 8)
> + /* Put the sign in front of Infinity */
> + p4[nb - 9] = (gfc_char4_t) fin;
> + }
> return;
> }
>
> - if (nb > 8)
> + if (nb > mark)
> /* We have room, so output 'Infinity' */
> memcpy(p + nb - 8, "Infinity", 8);
> else
> @@ -745,10 +760,13 @@ write_infnan (st_parameter_dt *dtp, const fnode *f
> for the sign and 'Infinity' so we go with 'Inf' */
> memcpy(p + nb - 3, "Inf", 3);
>
> - if (nb < 9 && nb > 3)
> - p[nb - 4] = fin; /* Put the sign in front of Inf */
> - else if (nb > 8)
> - p[nb - 9] = fin; /* Put the sign in front of Infinity */
> + if (sign == S_PLUS || sign == S_MINUS)
> + {
> + if (nb < 9 && nb > 3)
> + p[nb - 4] = fin; /* Put the sign in front of Inf */
> + else if (nb > 8)
> + p[nb - 9] = fin; /* Put the sign in front of Infinity */
> + }
> }
> else
> {
> Index: gfortran.dg/read_infnan_1.f90
> ===================================================================
> --- gfortran.dg/read_infnan_1.f90 (revision 169374)
> +++ gfortran.dg/read_infnan_1.f90 (working copy)
> @@ -22,9 +22,9 @@ read(10,'(7f10.3)') x4
> rewind(10)
> read(10,'(7f10.3)') x8
> write (output, '("x4 =",7G6.0)') x4
> -if (output.ne."x4 = +Inf NaN +Inf NaN -Inf NaN +Inf") call abort
> +if (output.ne."x4 = Inf NaN Inf NaN -Inf NaN Inf") call abort
> write (output, '("x8 =",7G6.0)') x8
> -if (output.ne."x8 = +Inf NaN +Inf NaN -Inf NaN +Inf") call abort
> +if (output.ne."x8 = Inf NaN Inf NaN -Inf NaN Inf") call abort
> !print '("x4 =",7G6.0)', x4
> !print '("x8 =",7G6.0)', x8
> end program pr43298
> Index: gfortran.dg/module_nan.f90
> ===================================================================
> --- gfortran.dg/module_nan.f90 (revision 169374)
> +++ gfortran.dg/module_nan.f90 (working copy)
> @@ -19,7 +19,7 @@ program a
> if (log(abs(inf)) < huge(inf)) call abort()
> if (log(abs(minf)) < huge(inf)) call abort()
> if (.not. isnan(nan)) call abort()
> - write(str,*) inf
> + write(str,"(sp,f10.2)") inf
> if (adjustl(str) /= "+Infinity") call abort()
> write(str,*) minf
> if (adjustl(str) /= "-Infinity") call abort()
> Index: gfortran.dg/char4_iunit_1.f03
> ===================================================================
> --- gfortran.dg/char4_iunit_1.f03 (revision 169374)
> +++ gfortran.dg/char4_iunit_1.f03 (working copy)
> @@ -26,9 +26,9 @@ program char4_iunit_1
> write(string, *) 1.2345e-06, 4.2846e+10_8
> if (string .ne. 4_" 1.23450002E-06 42846000000.000000 ") call abort
> write(string, *) nan, inf
> - if (string .ne. 4_" NaN +Infinity ") call abort
> + if (string .ne. 4_" NaN Infinity ") call abort
> write(string, '(10x,f3.1,3x,f9.1)') nan, inf
> - if (string .ne. 4_" NaN +Infinity ") call abort
> + if (string .ne. 4_" NaN Infinity ") call abort
> write(string, *) (1.2, 3.4 )
> if (string .ne. 4_" ( 1.2000000 , 3.4000001 ) ") call abort
> end program char4_iunit_1
> Index: gfortran.dg/large_real_kind_1.f90
> ===================================================================
> --- gfortran.dg/large_real_kind_1.f90 (revision 169374)
> +++ gfortran.dg/large_real_kind_1.f90 (working copy)
> @@ -56,7 +56,7 @@ program test
> call testoutput (-7.51e-100_k,-7.51e-100_8,15,'(F15.10)')
>
> x = huge(x)
> - call outputstring (2*x,'(F20.15)',' +Infinity')
> + call outputstring (2*x,'(F20.15)',' Infinity')
> call outputstring (-2*x,'(F20.15)',' -Infinity')
>
> write (c1,'(G20.10E5)') x
> Index: gfortran.dg/nan_7.f90
> ===================================================================
> --- gfortran.dg/nan_7.f90 (revision 0)
> +++ gfortran.dg/nan_7.f90 (revision 0)
> @@ -0,0 +1,14 @@
> +! { dg-do run }
> +! PR47293 NAN not correctly read
> +character(len=200) :: str
> +real(16) :: r, x, y, z
> +integer(16) :: k1, k2
> +x = 0.0
> +y = 0.0
> +r = 1.0
> +str = 'NAN' ; read(str,*) r
> +z = x/y
> +k1 = transfer(z,k1)
> +k2 = transfer(r,k2)
> +if (k1.ne.k2) call abort
> +end
> Index: gfortran.dg/real_const_3.f90
> ===================================================================
> --- gfortran.dg/real_const_3.f90 (revision 169374)
> +++ gfortran.dg/real_const_3.f90 (working copy)
> @@ -16,7 +16,7 @@ program main
> b = 1/exp(1000.0)
>
> write(str,*) a
> - if (trim(adjustl(str)) .ne. '+Infinity') call abort
> + if (trim(adjustl(str)) .ne. 'Infinity') call abort
>
> if (b .ne. 0.) call abort
>
> @@ -36,7 +36,7 @@ program main
> if (trim(adjustl(str)) .ne. '-Infinity') call abort
>
> write(str,*) 3.0/0.
> - if (trim(adjustl(str)) .ne. '+Infinity') call abort
> + if (trim(adjustl(str)) .ne. 'Infinity') call abort
>
> write(str,*) nan
> if (trim(adjustl(str)) .ne. 'NaN') call abort
> @@ -48,7 +48,7 @@ program main
> if (trim(adjustl(str)) .ne. '( NaN, NaN)') call abort
>
> write(str,*) z3
> - if (trim(adjustl(str)) .ne. '( +Infinity, -Infinity)') call abort
> + if (trim(adjustl(str)) .ne. '( Infinity, -Infinity)') call abort
>
> write(str,*) z4
> if (trim(adjustl(str)) .ne. '( 0.0000000 , -0.0000000 )') call abort
> Index: gfortran.fortran-torture/execute/nan_inf_fmt.f90
> ===================================================================
> --- gfortran.fortran-torture/execute/nan_inf_fmt.f90 (revision 169374)
> +++ gfortran.fortran-torture/execute/nan_inf_fmt.f90 (working copy)
> @@ -1,4 +1,5 @@
> !pr 12839- F2003 formatting of Inf /Nan
> +! Modified for PR47434
> implicit none
> character*40 l
> character*12 fmt
> @@ -15,11 +16,11 @@
> ! check a field width = 0
> fmt = '(F0.0)'
> write(l,fmt=fmt)pos_inf
> - if (l.ne.'+Inf') call abort
> + if (l.ne.'Inf') call abort
> write(l,fmt=fmt)neg_inf
> if (l.ne.'-Inf') call abort
> write(l,fmt=fmt)nan
> - if (l.ne.' NaN') call abort
> + if (l.ne.'NaN') call abort
>
> ! check a field width < 3
> fmt = '(F2.0)'
> @@ -42,7 +43,7 @@
> ! check a field width > 3
> fmt = '(F4.0)'
> write(l,fmt=fmt)pos_inf
> - if (l.ne.'+Inf') call abort
> + if (l.ne.' Inf') call abort
> write(l,fmt=fmt)neg_inf
> if (l.ne.'-Inf') call abort
> write(l,fmt=fmt)nan
> @@ -51,7 +52,7 @@
> ! check a field width = 7
> fmt = '(F7.0)'
> write(l,fmt=fmt)pos_inf
> - if (l.ne.' +Inf') call abort
> + if (l.ne.' Inf') call abort
> write(l,fmt=fmt)neg_inf
> if (l.ne.' -Inf') call abort
> write(l,fmt=fmt)nan
> @@ -60,7 +61,7 @@
> ! check a field width = 8
> fmt = '(F8.0)'
> write(l,fmt=fmt)pos_inf
> - if (l.ne.' +Inf') call abort
> + if (l.ne.'Infinity') call abort
> write(l,fmt=fmt)neg_inf
> if (l.ne.' -Inf') call abort
> write(l,fmt=fmt)nan
> @@ -69,7 +70,7 @@
> ! check a field width = 9
> fmt = '(F9.0)'
> write(l,fmt=fmt)pos_inf
> - if (l.ne.'+Infinity') call abort
> + if (l.ne.' Infinity') call abort
> write(l,fmt=fmt)neg_inf
> if (l.ne.'-Infinity') call abort
> write(l,fmt=fmt)nan
> @@ -78,7 +79,7 @@
> ! check a field width = 14
> fmt = '(F14.0)'
> write(l,fmt=fmt)pos_inf
> - if (l.ne.' +Infinity') call abort
> + if (l.ne.' Infinity') call abort
> write(l,fmt=fmt)neg_inf
> if (l.ne.' -Infinity') call abort
> write(l,fmt=fmt)nan
> module nonordinal
> implicit none
> real, parameter :: inf = 1./0., nan = 0./0., minf = -1./0.0
> end module nonordinal
>
>
> program testnan
> use nonordinal
> implicit none
> character(kind=4,len=20) :: str
> print "(F0.2)", nan
> print "(F3.2)", nan
> print "(sp,F0.2)", inf ! SIGN=PLUS
> print "(ss,F0.2)", inf ! SIGN=SUPPRESS
> print "(s, F0.2)", inf ! SIGN=PROCESSOR_DEFINED
> print "(sp,F1.2)", inf ! SIGN=PLUS
> print "(ss,F1.2)", inf ! SIGN=SUPPRESS
> print "(s, F1.2)", inf ! SIGN=PROCESSOR_DEFINED
> print "(sp,F2.2)", inf ! SIGN=PLUS
> print "(ss,F2.2)", inf ! SIGN=SUPPRESS
> print "(s, F2.2)", inf ! SIGN=PROCESSOR_DEFINED
> print "(sp,F3.2)", inf ! SIGN=PLUS
> print "(ss,F3.2)", inf ! SIGN=SUPPRESS
> print "(s, F3.2)", inf ! SIGN=PROCESSOR_DEFINED
> print "(sp,F4.2)", inf ! SIGN=PLUS
> print "(ss,F4.2)", inf ! SIGN=SUPPRESS
> print "(s, F4.2)", inf ! SIGN=PROCESSOR_DEFINED
> print "(sp,F5.2)", inf ! SIGN=PLUS
> print "(ss,F5.2)", inf ! SIGN=SUPPRESS
> print "(s, F5.2)", inf ! SIGN=PROCESSOR_DEFINED
> print "(sp,F6.2)", inf ! SIGN=PLUS
> print "(ss,F6.2)", inf ! SIGN=SUPPRESS
> print "(s, F6.2)", inf ! SIGN=PROCESSOR_DEFINED
> print "(sp,F7.2)", inf ! SIGN=PLUS
> print "(ss,F7.2)", inf ! SIGN=SUPPRESS
> print "(s, F7.2)", inf ! SIGN=PROCESSOR_DEFINED
> print "(sp,F8.2)", inf ! SIGN=PLUS
> print "(ss,F8.2)", inf ! SIGN=SUPPRESS
> print "(s, F8.2)", inf ! SIGN=PROCESSOR_DEFINED
> print "(sp,F9.2)", inf ! SIGN=PLUS
> print "(ss,F9.2)", inf ! SIGN=SUPPRESS
> print "(s, F9.2)", inf ! SIGN=PROCESSOR_DEFINED
> print "(sp,F10.2)", inf ! SIGN=PLUS
> print "(ss,F10.2)", inf ! SIGN=SUPPRESS
> print "(s, F10.2)", inf ! SIGN=PROCESSOR_DEFINED
> print "(sp,F11.2)", inf ! SIGN=PLUS
> print "(ss,F11.2)", inf ! SIGN=SUPPRESS
> print "(s, F11.2)", inf ! SIGN=PROCESSOR_DEFINED
> if (log(abs(inf)) < huge(inf)) print *, 49
> if (log(abs(minf)) < huge(inf)) print *, 50
> if (.not. isnan(nan)) print *, 51
> write(str,"(sp,f10.2)") inf
> if (adjustl(str) /= 4_"+Infinity") print *, 53, str
> write(str,*) minf
> if (adjustl(str) /= 4_"-Infinity") print *, 55
> write(str,*) nan
> if (adjustl(str) /= 4_"NaN") print *, 57
> end program testnan
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch, libgfortran] PR47434 Wrong field width for NaN with (F0.n) formatting
2011-01-29 17:31 ` Jack Howarth
@ 2011-01-29 18:44 ` Jerry DeLisle
0 siblings, 0 replies; 9+ messages in thread
From: Jerry DeLisle @ 2011-01-29 18:44 UTC (permalink / raw)
To: Jack Howarth; +Cc: gfortran, gcc patches
On 01/29/2011 07:10 AM, Jack Howarth wrote:
---- snip ----
>
> Jerry,
> This patch causes the regressions...
>
> FAIL: gfortran.dg/nan_7.f90 -O0 (test for excess errors)
> WARNING: gfortran.dg/nan_7.f90 -O0 compilation failed to produce executable
I did not intend to include that test case yet. It is part of the libquadmath
patch that I have not committed yet. I have Jakubs comments incorporated, but
the test configure requires some magic yet. This is PR47293. The rest of
PR47434 I will commit.
Sorry for the noise there.
Jerry
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch, libgfortran] PR47434 Wrong field width for NaN with (F0.n) formatting
2011-01-29 0:29 [patch, libgfortran] PR47434 Wrong field width for NaN with (F0.n) formatting Jerry DeLisle
2011-01-29 17:31 ` Jack Howarth
@ 2011-01-29 17:56 ` Tobias Burnus
2011-01-30 18:14 ` Gerald Pfeifer
1 sibling, 1 reply; 9+ messages in thread
From: Tobias Burnus @ 2011-01-29 17:56 UTC (permalink / raw)
To: Jerry DeLisle; +Cc: gfortran, gcc patches
[-- Attachment #1: Type: text/plain, Size: 608 bytes --]
Jerry DeLisle wrote:
> 2011-01-28 Jerry DeLisle <jvdelisle@gcc.gnu.org>
>
> PR libgfortran/47434
> * io/write_float.def (write_infnan): Use calculate_sign to determine
> if the sign should be given and check field widths accordingly.
Regarding the test cases:
* pr47434.f90
You need to add: ! { dg-add-options ieee }
* gfortran.dg/nan_7.f90
You need to add:
! { dg-require-effective-target fortran_quad_real }
! { dg-add-options ieee }
But you additionally need to apply the attached patch.
I am not sure who can/needs to review the patch for
gcc/testsuite/lib/target-supports.exp
Tobias
[-- Attachment #2: quad.diff --]
[-- Type: text/x-patch, Size: 897 bytes --]
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index ee7a8bf..aad4560 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -945,6 +945,23 @@ proc check_effective_target_fortran_large_real { } {
}]
}
+# Return 1 if the target supports Fortran real kind real(16),
+# 0 otherwise. Contrary to check_effective_target_fortran_large_real
+# this checks for Real(16) only; the other returned real(10) if
+# both real(10) and real(16) are available.
+#
+# When the target name changes, replace the cached result.
+
+proc check_effective_target_fortran_quad_real { } {
+ return [check_no_compiler_messages fortran_large_real executable {
+ ! Fortran
+ real(kind=16) :: x
+ x = cos (x)
+ end
+ }]
+}
+
+
# Return 1 if the target supports Fortran integer kinds larger than
# integer(8), 0 otherwise.
#
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch, libgfortran] PR47434 Wrong field width for NaN with (F0.n) formatting
2011-01-29 17:56 ` Tobias Burnus
@ 2011-01-30 18:14 ` Gerald Pfeifer
2011-01-30 18:39 ` Jerry DeLisle
0 siblings, 1 reply; 9+ messages in thread
From: Gerald Pfeifer @ 2011-01-30 18:14 UTC (permalink / raw)
To: Tobias Burnus; +Cc: Jerry DeLisle, fortran, gcc-patches
On Sat, 29 Jan 2011, Tobias Burnus wrote:
> But you additionally need to apply the attached patch.
>
> I am not sure who can/needs to review the patch for
> gcc/testsuite/lib/target-supports.exp
Practically I'd suggest to handle this like a "simple" Fortran
patch, that is, have it reviewed/approved by one of the other
Fortran maintainers.
Gerald
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch, libgfortran] PR47434 Wrong field width for NaN with (F0.n) formatting
2011-01-30 18:14 ` Gerald Pfeifer
@ 2011-01-30 18:39 ` Jerry DeLisle
2011-01-30 20:22 ` Tobias Burnus
0 siblings, 1 reply; 9+ messages in thread
From: Jerry DeLisle @ 2011-01-30 18:39 UTC (permalink / raw)
To: Gerald Pfeifer; +Cc: Tobias Burnus, fortran, gcc-patches
On 01/30/2011 09:08 AM, Gerald Pfeifer wrote:
> On Sat, 29 Jan 2011, Tobias Burnus wrote:
>> But you additionally need to apply the attached patch.
>>
>> I am not sure who can/needs to review the patch for
>> gcc/testsuite/lib/target-supports.exp
>
> Practically I'd suggest to handle this like a "simple" Fortran
> patch, that is, have it reviewed/approved by one of the other
> Fortran maintainers.
>
OK, well Tobias, if you review and approve, I will commit. Looks pretty safe to me.
Jerry
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch, libgfortran] PR47434 Wrong field width for NaN with (F0.n) formatting
2011-01-30 18:39 ` Jerry DeLisle
@ 2011-01-30 20:22 ` Tobias Burnus
0 siblings, 0 replies; 9+ messages in thread
From: Tobias Burnus @ 2011-01-30 20:22 UTC (permalink / raw)
To: Jerry DeLisle; +Cc: Gerald Pfeifer, fortran, gcc-patches
Jerry DeLisle wrote:
> On 01/30/2011 09:08 AM, Gerald Pfeifer wrote:
>> On Sat, 29 Jan 2011, Tobias Burnus wrote:
>>> But you additionally need to apply the attached patch.
>>>
>>> I am not sure who can/needs to review the patch for
>>> gcc/testsuite/lib/target-supports.exp
>>
>> Practically I'd suggest to handle this like a "simple" Fortran
>> patch, that is, have it reviewed/approved by one of the other
>> Fortran maintainers.
>>
> OK, well Tobias, if you review and approve, I will commit. Looks
> pretty safe to me.
>
The gcc/testsuite/lib/target-supports.exp part
of http://gcc.gnu.org/ml/fortran/2011-01/msg00302.html
is OK.
(I did not look at nan_7.f90 as it first requires the libquadmath changes.)
Tobias
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch, libgfortran] PR47434 Wrong field width for NaN with (F0.n) formatting
@ 2011-01-30 20:47 Dominique Dhumieres
2011-01-30 22:26 ` Jerry DeLisle
0 siblings, 1 reply; 9+ messages in thread
From: Dominique Dhumieres @ 2011-01-30 20:47 UTC (permalink / raw)
To: fortran; +Cc: gcc-patches, gerald, burnus, jvdelisle
> (I did not look at nan_7.f90 as it first requires the libquadmath changes.)
I have regtested the full patch on x86_64-apple-darwin10.6.0 and tested nan_7.f90 on
powerpc-apple-darwin9. My only concern is about nan_7.f90 that can be not enough
selective, but I did not find anything more selective and working for both
float_128 and the ppc real(16) made of two real(8). Unless someone comes with
a better test soon, I think the patch should be commited as such.
Thanks for the fix,
Dominique
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch, libgfortran] PR47434 Wrong field width for NaN with (F0.n) formatting
2011-01-30 20:47 Dominique Dhumieres
@ 2011-01-30 22:26 ` Jerry DeLisle
0 siblings, 0 replies; 9+ messages in thread
From: Jerry DeLisle @ 2011-01-30 22:26 UTC (permalink / raw)
To: Dominique Dhumieres; +Cc: fortran, gcc-patches, gerald, burnus
On 01/30/2011 11:29 AM, Dominique Dhumieres wrote:
>> (I did not look at nan_7.f90 as it first requires the libquadmath changes.)
>
> I have regtested the full patch on x86_64-apple-darwin10.6.0 and tested nan_7.f90 on
> powerpc-apple-darwin9. My only concern is about nan_7.f90 that can be not enough
> selective, but I did not find anything more selective and working for both
> float_128 and the ppc real(16) made of two real(8). Unless someone comes with
> a better test soon, I think the patch should be commited as such.
>
> Thanks for the fix,
>
> Dominique
>
Thanks for testing Dominique, I can not thing of a better test at the moment.
The patch itself for libquadmath I am sure is OK. Maybe I should commit to see
if any platforms fail the nan_7.f90 test.
Jerry
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2011-01-30 19:40 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-29 0:29 [patch, libgfortran] PR47434 Wrong field width for NaN with (F0.n) formatting Jerry DeLisle
2011-01-29 17:31 ` Jack Howarth
2011-01-29 18:44 ` Jerry DeLisle
2011-01-29 17:56 ` Tobias Burnus
2011-01-30 18:14 ` Gerald Pfeifer
2011-01-30 18:39 ` Jerry DeLisle
2011-01-30 20:22 ` Tobias Burnus
2011-01-30 20:47 Dominique Dhumieres
2011-01-30 22:26 ` 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).