Patchwork [libquadmath,committed] Fix exponent reading

login
register
mail settings
Submitter Tobias Burnus
Date Dec. 4, 2012, 4:03 p.m.
Message ID <50BE1EBE.8020308@net-b.de>
Download mbox | patch
Permalink /patch/203685/
State New
Headers show

Comments

Tobias Burnus - Dec. 4, 2012, 4:03 p.m.
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
David Edelsohn - Dec. 4, 2012, 4:06 p.m.
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
Jakub Jelinek - Dec. 4, 2012, 4:07 p.m.
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

Patch

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)