From 36402bb1864531f22acc9c3ef2403e1d3cddfc65 Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Mon, 3 Dec 2012 17:16:28 +0100 Subject: [PATCH] strtod_l.c (___STRTOF_INTERNAL): Fix exponent reading. 2012-12-03 Tobias Burnus * strtod/strtod_l.c (___STRTOF_INTERNAL): Fix exponent reading. 2012-12-03 Tobias Burnus * gfortran.dg/quad_3.f90: New. From-SVN: r194100 --- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gfortran.dg/quad_3.f90 | 27 +++++++++++++++++++++++++++ libquadmath/ChangeLog | 5 +++++ libquadmath/strtod/strtod_l.c | 3 +++ 4 files changed, 39 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/quad_3.f90 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 89e7a793583..e6fe2a00b76 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2012-12-03 Tobias Burnus + + * gfortran.dg/quad_3.f90: New. + 2012-12-03 Paolo Carlini PR c++/54170 diff --git a/gcc/testsuite/gfortran.dg/quad_3.f90 b/gcc/testsuite/gfortran.dg/quad_3.f90 new file mode 100644 index 00000000000..e29dac229b8 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/quad_3.f90 @@ -0,0 +1,27 @@ +! { dg-do run } +! +! I/O test for REAL(16) +! +! Contributed by Dominique d'Humieres +! +program test_qp + use iso_fortran_env, only: real_kinds + implicit none + integer, parameter :: QP = real_kinds(ubound(real_kinds,dim=1)) + real(kind=qp) :: a,b(2), c + integer :: exponent + character(len=180) :: tmp + + ! Run this only with libquadmath; assume that all those systems + ! have also kind=10. + if (size (real_kinds) >= 4 .and. real_kinds(3) == 10 .and. qp == 16) then + exponent = 4000 + b(:) = huge (1.0_qp)/10.0_qp**exponent +! print *, 'real(16) big value: ', b(1) + write (tmp, *) b + read (tmp, *) a, c +! print *, 'same value read again: ', a, c +! print *, 'difference: looks OK now ', a-b(1) + if (a-b(1) /= 0.0_qp .or. c-b(1) /= 0.0_qp) call abort() + end if +end program test_qp diff --git a/libquadmath/ChangeLog b/libquadmath/ChangeLog index 8b052dcf390..867ab48b989 100644 --- a/libquadmath/ChangeLog +++ b/libquadmath/ChangeLog @@ -1,3 +1,8 @@ +2012-12-03 Tobias Burnus + + * strtod/strtod_l.c (___STRTOF_INTERNAL): Fix exponent + reading. + 2012-11-25 Tobias Burnus PR libquadmath/55462 diff --git a/libquadmath/strtod/strtod_l.c b/libquadmath/strtod/strtod_l.c index cd0c1f2da25..d1845a8039c 100644 --- a/libquadmath/strtod/strtod_l.c +++ b/libquadmath/strtod/strtod_l.c @@ -1005,6 +1005,9 @@ ____STRTOF_INTERNAL (nptr, endptr, group) /* NOTREACHED */ } + exponent *= 10; + exponent += c - L_('0'); + c = *++cp; } while (c >= L_('0') && c <= L_('9'));