aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJerry DeLisle <jvdelisle@gcc.gnu.org>2024-10-17 13:39:09 -0700
committerJerry DeLisle <jvdelisle@gcc.gnu.org>2024-10-17 13:49:04 -0700
commit6604a05fa27bc21c3409e767552daca3fcf43964 (patch)
treea5ec0d81d8e6db76612611696bc4f2c2889bd513
parent71386491ff601fba3566376d90dfdc0530df2680 (diff)
downloadgcc-6604a05fa27bc21c3409e767552daca3fcf43964.zip
gcc-6604a05fa27bc21c3409e767552daca3fcf43964.tar.gz
gcc-6604a05fa27bc21c3409e767552daca3fcf43964.tar.bz2
Fortran: Add tolerance to real value comparisons.
gcc/testsuite/ChangeLog: PR fortran/105361 * gfortran.dg/pr105361.f90: In the comparisons of real values after a read, use a tolerance so that subtle differences in results between different architectures do not fail.
-rw-r--r--gcc/testsuite/gfortran.dg/pr105361.f9012
1 files changed, 8 insertions, 4 deletions
diff --git a/gcc/testsuite/gfortran.dg/pr105361.f90 b/gcc/testsuite/gfortran.dg/pr105361.f90
index 62821c2..fc09ad6 100644
--- a/gcc/testsuite/gfortran.dg/pr105361.f90
+++ b/gcc/testsuite/gfortran.dg/pr105361.f90
@@ -3,7 +3,7 @@
module x
implicit none
type foo
- real :: r
+ real(4) :: r
end type foo
interface read(formatted)
module procedure read_formatted
@@ -25,17 +25,21 @@ program main
use x
implicit none
type(foo) :: a, b
- real :: c, d
+ real(4) :: c, d
+ c = 0.0_4
+ d = 0.0_4
open(10, access="stream")
write(10) "1 2" // NEW_LINE('A')
close(10)
open(10)
read(10,*) c, d
- if ((c /= 1.0) .or. (d /= 2.0)) stop 1
+ if ((abs(c - 1.0_4) .gt. 0.001_4) .or. (abs(d - 2.0_4) .gt. 0.001_4)) stop 1
rewind(10)
!print *, c,d
+ a%r = 0.0_4
+ b%r = 0.0_4
read (10,*) a, b
close(10, status="delete")
- if ((a%r /= 1.0) .or. (b%r /= 2.0)) stop 2
+ if ((abs(a%r - 1.0_4) .gt. 0.001_4) .or. (abs(b%r - 2.0_4) .gt. 0.001_4)) stop 2
!print *, a,b
end program main