This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/32393] gfortran - incorrect run time results



------- Comment #24 from burnus at gcc dot gnu dot org  2007-06-22 13:26 -------
Additional note - as pointed out by Ian of NAG:
      program main
      implicit none
      integer :: jt, it(100)
      real    :: tt
      equivalence    (jt,tt)
      do i=1,100
        tt=i
        it(i)=jt
      end do
      end program main

Here "jt" is *undefined*. The Fortran 2003 standard has in Section 16.5.6:
"When a variable of a given type becomes defined, all associated
variables of different type become undefined." (There is an exception for real
vs. complex variables.)

That mean "jt" can contain any value according to the standard (cf. "union" in
C). In reality, after assigning real(ii) to tt, jt has a defined value - which
some programs make use of.

Fortran 2003 standard conform would be not: "it(i) = jt", but
"it(i)=transfer(tt,0)", which gives however the same result in practice.


-- 


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]