http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50619

             Bug #: 50619
           Summary: Surprising interaction between  -finit-real=NAN and
                    the associate construct
    Classification: Unclassified
           Product: gcc
           Version: 4.6.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: fkrogh#g...@mathalacarte.com


With a real variable defined in a derived type and referenced in an associate
construct the value is redefined as a NaN when using the compilier flag
-finit-real=NAN.  The following two short routines illustrate the problem.


program testa1
  use testa2
  type(test_ty) :: e
  call test(e)
  stop
end program testa1

module testa2
type, public ::  test_ty ! Values that can be set or looked at by the user.
  real :: rmult = 1.0e0 ! Multiplies reals using default format.
end type test_ty

contains
  subroutine test(e)
    type(test_ty) :: e
    print '("No associate: e%rmult =", es15.6)', e%rmult
    associate (rmult=>e%rmult)
      print '("Associate: %rmult =", es15.6)', e%rmult
    end associate
  end subroutine test
end module testa2

compile with

gfortran  -ggdb -finit-real=NAN  -o testa1 testa2.f90 testa1.f90

and get

No associate: e%rmult =   1.000000E+00
Associate: %rmult =            NaN

Reply via email to