This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/32393] gfortran - incorrect run time results
- From: "burnus at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 22 Jun 2007 13:26:53 -0000
- Subject: [Bug fortran/32393] gfortran - incorrect run time results
- References: <bug-32393-10129@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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