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

            Bug ID: 58975
           Summary: Builtin function RAN() interferes with F77 program's
                    own definition of INTEGER FUNCTION RAN()
           Product: gcc
           Version: 4.8.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: arthur.j.odwyer at gmail dot com

Related to Bug 14993.

"Adventure II" works perfectly with the old f77 compiler, but crashes under
gfortran.

http://www.mipmip.org/adv440/index.shtml
http://www.ifarchive.org/if-archive/games/source/adv440.tgz

If you compile the above-linked Fortran 77 program ("advII.f") with gfortran
4.8.1, you'll observe that it crashes every time the player enters an area
forbidden to dwarves. This is because that particular computation involves
random number generation, which in "advII.f" is implemented like this:

      INTEGER FUNCTION RAN(IR)
      [...snip...]
      IRAN=MOD(R,173)
      RAN=MOD(R,IR)
      RETURN
      END

and used like this:

      PCT(N)=RAN(100).LT.N

The problem is that the call to RAN(100) above is being turned into a call to
the RAN() built-in real-valued function, rather than the integer function
defined above. This leads to nonsensical codegen.

When a Fortran 77 program defines its own version of RAN(), the program's
version should override the compiler's built-in.

Reply via email to