* Re: [libquadmath, patch, committed] Fix exponent reading
@ 2012-12-04 14:35 David Edelsohn
2012-12-04 16:03 ` Tobias Burnus
0 siblings, 1 reply; 6+ messages in thread
From: David Edelsohn @ 2012-12-04 14:35 UTC (permalink / raw)
To: Tobias Burnus; +Cc: GCC Patches
Tobias,
The quad_3.f90 testcase fails on AIX, which does not have quad math enabled.
I do not understand how the following line can be correct. Fortran
does not have early exit and the line is evaluated at compile time, so
real_kinds(3) is not valid because real_kinds array does not have that
many elements.
if (size (real_kinds) >= 4 .and. real_kinds(3) == 10 .and. qp == 16) then
Thanks, David
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [libquadmath, patch, committed] Fix exponent reading
2012-12-04 14:35 [libquadmath, patch, committed] Fix exponent reading David Edelsohn
@ 2012-12-04 16:03 ` Tobias Burnus
2012-12-04 16:06 ` David Edelsohn
2012-12-04 16:07 ` Jakub Jelinek
0 siblings, 2 replies; 6+ messages in thread
From: Tobias Burnus @ 2012-12-04 16:03 UTC (permalink / raw)
To: David Edelsohn; +Cc: GCC Patches
[-- Attachment #1: Type: text/plain, Size: 510 bytes --]
David Edelsohn:
> The quad_3.f90 testcase fails on AIX, which does not have quad math enabled. I do not understand how the following line can be correct.
Well, obviously, it is not correct - otherwise you wouldn't see a
failure :-)
Corrected by the attached patch (Rev. 194155).
Sorry for the mistake.
> Fortran does not have early exit
Not yet. (It has been proposed for F2003 but specifying the exact
semantics/syntax was that difficult that it has been postponed until
some future revision.)
Tobias
[-- Attachment #2: committed.diff --]
[-- Type: text/x-patch, Size: 955 bytes --]
Index: ChangeLog
===================================================================
--- ChangeLog (Revision 194152)
+++ ChangeLog (Arbeitskopie)
@@ -1,3 +1,8 @@
+2012-12-04 Tobias Burnus <burnus@net-b.de>
+
+ * gfortran.dg/quad_3.f90: Fix a condition,
+ which wrongly required ordered/lazy evaluation.
+
2012-12-04 Marcus Shawcroft <marcus.shawcroft@arm.com>
* gcc.target/aarch64/121127.c: New test.
Index: gfortran.dg/quad_3.f90
===================================================================
--- gfortran.dg/quad_3.f90 (Revision 194152)
+++ gfortran.dg/quad_3.f90 (Arbeitskopie)
@@ -15,6 +15,8 @@ program test_qp
! 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
+ if (real_kinds(3) /= 10) stop
+
exponent = 4000
b(:) = huge (1.0_qp)/10.0_qp**exponent
! print *, 'real(16) big value: ', b(1)
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [libquadmath, patch, committed] Fix exponent reading
2012-12-04 16:03 ` Tobias Burnus
@ 2012-12-04 16:06 ` David Edelsohn
2012-12-04 16:44 ` Tobias Burnus
2012-12-04 16:07 ` Jakub Jelinek
1 sibling, 1 reply; 6+ messages in thread
From: David Edelsohn @ 2012-12-04 16:06 UTC (permalink / raw)
To: Tobias Burnus; +Cc: GCC Patches
Tobias,
I have not tried this patch, but will it actually fix it? The error
is real_kinds(3) is outside the array bounds. Your patch fixes
addresses a runtime problem, not a compile-time problem, if I
understand correctly.
/nasfarm/dje/src/src/gcc/testsuite/gfortran.dg/quad_3.f90:17.47:
if (size (real_kinds) >= 4 .and. real_kinds(3) == 10 .and. qp == 16) then
1
Warning: Array reference at (1) is out of bounds (3 > 2) in dimension 1
/nasfarm/dje/src/src/gcc/testsuite/gfortran.dg/quad_3.f90:17.47:
if (size (real_kinds) >= 4 .and. real_kinds(3) == 10 .and. qp == 16) then
1
Error: Index in dimension 1 is out of bounds at (1)
I do not think that you patch will affect the compile-time error.
thanks, David
On Tue, Dec 4, 2012 at 11:03 AM, Tobias Burnus <burnus@net-b.de> wrote:
> David Edelsohn:
>
>> The quad_3.f90 testcase fails on AIX, which does not have quad math
>> enabled. I do not understand how the following line can be correct.
>
>
> Well, obviously, it is not correct - otherwise you wouldn't see a failure
> :-)
> Corrected by the attached patch (Rev. 194155).
>
> Sorry for the mistake.
>
>
>> Fortran does not have early exit
>
>
> Not yet. (It has been proposed for F2003 but specifying the exact
> semantics/syntax was that difficult that it has been postponed until some
> future revision.)
>
> Tobias
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [libquadmath, patch, committed] Fix exponent reading
2012-12-04 16:03 ` Tobias Burnus
2012-12-04 16:06 ` David Edelsohn
@ 2012-12-04 16:07 ` Jakub Jelinek
1 sibling, 0 replies; 6+ messages in thread
From: Jakub Jelinek @ 2012-12-04 16:07 UTC (permalink / raw)
To: Tobias Burnus; +Cc: David Edelsohn, GCC Patches
On Tue, Dec 04, 2012 at 05:03:10PM +0100, Tobias Burnus wrote:
> +2012-12-04 Tobias Burnus <burnus@net-b.de>
> +
> + * gfortran.dg/quad_3.f90: Fix a condition,
> + which wrongly required ordered/lazy evaluation.
> +
> 2012-12-04 Marcus Shawcroft <marcus.shawcroft@arm.com>
>
> * gcc.target/aarch64/121127.c: New test.
> Index: gfortran.dg/quad_3.f90
> ===================================================================
> --- gfortran.dg/quad_3.f90 (Revision 194152)
> +++ gfortran.dg/quad_3.f90 (Arbeitskopie)
> @@ -15,6 +15,8 @@ program test_qp
> ! 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
> + if (real_kinds(3) /= 10) stop
How does this fix it? Shouldn't you also remove .and. real_kinds(3) == 10
from the previous line? If .and. is not like C &&, then that still
accesses past the array size if real_kinds is smaller than 4 elements.
> +
> exponent = 4000
> b(:) = huge (1.0_qp)/10.0_qp**exponent
> ! print *, 'real(16) big value: ', b(1)
Jakub
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [libquadmath, patch, committed] Fix exponent reading
2012-12-04 16:06 ` David Edelsohn
@ 2012-12-04 16:44 ` Tobias Burnus
0 siblings, 0 replies; 6+ messages in thread
From: Tobias Burnus @ 2012-12-04 16:44 UTC (permalink / raw)
To: David Edelsohn; +Cc: GCC Patches
[-- Attachment #1: Type: text/plain, Size: 425 bytes --]
David Edelsohn wrote:
> I have not tried this patch, but will it actually fix it? The error
> is real_kinds(3) is outside the array bounds. Your patch fixes
> addresses a runtime problem, not a compile-time problem, if I
> understand correctly.
Yes, I realized it myself - after a hint by Dominique. The following
should fix it. I really shouldn't try to quickly fix such bugs while
working on something else :-(
Tobias
[-- Attachment #2: committed.diff --]
[-- Type: text/x-patch, Size: 1208 bytes --]
Index: ChangeLog
===================================================================
--- ChangeLog (Revision 194155)
+++ ChangeLog (Arbeitskopie)
@@ -1,5 +1,9 @@
2012-12-04 Tobias Burnus <burnus@net-b.de>
+ * gfortran.dg/quad_3.f90: Really fix an if condition.
+
+2012-12-04 Tobias Burnus <burnus@net-b.de>
+
* gfortran.dg/quad_3.f90: Fix a condition,
which wrongly required ordered/lazy evaluation.
Index: gfortran.dg/quad_3.f90
===================================================================
--- gfortran.dg/quad_3.f90 (Revision 194155)
+++ gfortran.dg/quad_3.f90 (Arbeitskopie)
@@ -9,13 +9,14 @@ program test_qp
implicit none
integer, parameter :: QP = real_kinds(ubound(real_kinds,dim=1))
real(kind=qp) :: a,b(2), c
- integer :: exponent
+ integer :: exponent, i
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
- if (real_kinds(3) /= 10) stop
+ if (size (real_kinds) >= 4 .and. qp == 16) then
+ i = 3
+ if (real_kinds(i) /= 10) stop
exponent = 4000
b(:) = huge (1.0_qp)/10.0_qp**exponent
^ permalink raw reply [flat|nested] 6+ messages in thread
* [libquadmath, patch, committed] Fix exponent reading
@ 2012-12-03 16:18 Tobias Burnus
0 siblings, 0 replies; 6+ messages in thread
From: Tobias Burnus @ 2012-12-03 16:18 UTC (permalink / raw)
To: gcc patches
[-- Attachment #1: Type: text/plain, Size: 221 bytes --]
Somehow that got lot when updating the file. I think, we really need a
proper test suite - the current quad_{1,2,3}.f90 are a first step, but
rather incomplete.
Committed as Rev. 194100 after build+regtesting.
Tobias
[-- Attachment #2: committed.diff --]
[-- Type: text/x-patch, Size: 2267 bytes --]
Index: libquadmath/ChangeLog
===================================================================
--- libquadmath/ChangeLog (Revision 194099)
+++ libquadmath/ChangeLog (Arbeitskopie)
@@ -1,3 +1,8 @@
+2012-12-03 Tobias Burnus <burnus@net-b.de>
+
+ * strtod/strtod_l.c (___STRTOF_INTERNAL): Fix exponent
+ reading.
+
2012-11-25 Tobias Burnus <burnus@net-b.de>
PR libquadmath/55462
Index: libquadmath/strtod/strtod_l.c
===================================================================
--- libquadmath/strtod/strtod_l.c (Revision 194099)
+++ libquadmath/strtod/strtod_l.c (Arbeitskopie)
@@ -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'));
Index: gcc/testsuite/ChangeLog
===================================================================
--- gcc/testsuite/ChangeLog (Revision 194099)
+++ gcc/testsuite/ChangeLog (Arbeitskopie)
@@ -1,3 +1,7 @@
+2012-12-03 Tobias Burnus <burnus@net-b.de>
+
+ * gfortran.dg/quad_3.f90: New.
+
2012-12-03 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/54170
Index: gcc/testsuite/gfortran.dg/quad_3.f90
===================================================================
--- gcc/testsuite/gfortran.dg/quad_3.f90 (Revision 0)
+++ gcc/testsuite/gfortran.dg/quad_3.f90 (Arbeitskopie)
@@ -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
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-12-04 16:44 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-04 14:35 [libquadmath, patch, committed] Fix exponent reading David Edelsohn
2012-12-04 16:03 ` Tobias Burnus
2012-12-04 16:06 ` David Edelsohn
2012-12-04 16:44 ` Tobias Burnus
2012-12-04 16:07 ` Jakub Jelinek
-- strict thread matches above, loose matches on Subject: below --
2012-12-03 16:18 Tobias Burnus
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).