Technical details of the -qfloat=hsflt option

The -qfloat=hsflt option is unsafe for optimized programs that compute floating-point values that are outside the range of representation of single precision, not just outside the range of the result type. The range of representation includes both the precision and the exponent range.

Even when you follow the rules that are stated in the preceding paragraph and in -qfloat option , programs that are sensitive to precision differences might not produce expected results. Because -qfloat=hsflt is not compliant with IEEE, programs will not always run as expected.

For example, in the following program, X.EQ.Y may be true or may be false:

    REAL X, Y, A(2)
    DOUBLE PRECISION Z
    LOGICAL SAME

    READ *, Z
    X = Z
    Y = Z
    IF (X.EQ.Y) SAME = .TRUE.
    ! ...
    ! ... Calculations that do not change X or Y
    ! ...
    CALL SUB(X)         ! X is stored in memory with truncated fraction.
    IF (X.EQ.Y) THEN    ! Result might be different than before.
    ...

    A(1) = Z
    X = Z
    A(2) = 1.           ! A(1) is stored in memory with truncated fraction.
    IF (A(1).EQ.X) THEN ! Result might be different than expected.
    ...

If the value of Z has fractional bits that are outside the precision of a single-precision variable, these bits may be preserved in some cases and lost in others. This makes the exact results unpredictable when the double-precision value of Z is assigned to single-precision variables. For example, passing the variable as a dummy argument causes its value to be stored in memory with a fraction that is truncated rather than rounded.