| 1 |
! { dg-do run } |
| 2 |
! PR fortran/109186 - Verify that NEAREST produces same results at |
| 3 |
! compile-time and run-time for corner cases |
| 4 |
! Reported by John Harper |
| 5 |
|
| 6 |
program p |
| 7 |
implicit none |
| 8 |
integer, parameter :: sp = selected_real_kind (6) |
| 9 |
integer, parameter :: dp = selected_real_kind (13) |
| 10 |
real(sp), parameter :: x1 = huge (1._sp), t1 = tiny (1._sp) |
| 11 |
real(dp), parameter :: x2 = huge (1._dp), t2 = tiny (1._dp) |
| 12 |
real(sp), volatile :: y1, z1 |
| 13 |
real(dp), volatile :: y2, z2 |
| 14 |
y1 = x1 |
| 15 |
z1 = nearest (y1, -1._sp) |
| 16 |
if (nearest (x1, -1._sp) /= z1) stop 1 |
| 17 |
y2 = x2 |
| 18 |
z2 = nearest (y2, -1._dp) |
| 19 |
if (nearest (x2, -1._dp) /= z2) stop 2 |
| 20 |
y1 = t1 |
| 21 |
z1 = nearest (y1, 1._sp) |
| 22 |
if (nearest (t1, 1._sp) /= z1) stop 3 |
| 23 |
y2 = t2 |
| 24 |
z2 = nearest (y2, 1._dp) |
| 25 |
if (nearest (t2, 1._dp) /= z2) stop 4 |
| 26 |
end |