| 1 |
! { dg-do run } |
| 2 |
! { dg-options "-fno-sign-zero" } |
| 3 |
! |
| 4 |
! PR fortran/40675 |
| 5 |
! |
| 6 |
! Fortran 77 just had: "The value of a signed zero is the same as |
| 7 |
! the value of an unsigned zero." and g77 returned for SIGN(1.0, -0.0) = 1.0 |
| 8 |
! |
| 9 |
! Fortran 95+ has for SIGN: "Case (iv): If B is of type real and is zero, |
| 10 |
! then ... (c) If B is negative real zero, the value of the result is -|A|". |
| 11 |
! On architectures, where signed zeros are supported, gfortran's SIGN thus |
| 12 |
! returns for B=-0.0 the -|A|. |
| 13 |
! |
| 14 |
program s |
| 15 |
x = sign(1.,0.) |
| 16 |
y = sign(1.,-0.) |
| 17 |
if (x /= 1.) STOP 1 |
| 18 |
if (y /= 1.) STOP 2 |
| 19 |
x = 1. |
| 20 |
y = 0. |
| 21 |
x = sign(x, y) |
| 22 |
y = sign(x, -y) |
| 23 |
if (x /= 1.) STOP 3 |
| 24 |
if (y /= 1.) STOP 4 |
| 25 |
end program s |