Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!samsung!uakari.primate.wisc.edu!uwm.edu!psuvax1!rutgers!deimos!ux1.cso.uiuc.edu!ux1.cso.uiuc.edu!hirchert From: hirchert@ux1.cso.uiuc.edu Newsgroups: comp.lang.misc Subject: Re: NOT Educating FORTRAN programme Message-ID: <7300005@ux1.cso.uiuc.edu> Date: 24 Jan 90 19:37:00 GMT References: <21403@pasteur.Berkeley.EDU> Lines: 30 Nf-ID: #R:pasteur.Berkeley.EDU:21403:ux1.cso.uiuc.edu:7300005:000:1661 Nf-From: ux1.cso.uiuc.edu!hirchert Jan 24 13:37:00 1990 Wayne Faustus (faustus@yew.Berkeley.EDU) asks: >I haven't used FORTRAN myself, but from these discussions it seems >to me that there are a lot of things you are not supposed to do to >make things nice for the compiler, like create aliases and allow foo() >in "x[i] + foo()" to alter x or i. Do FORTRAN compilers check these >constraints? If not, aren't they a great source of hard-to-find bugs, >that go away when you turn off optimization? For the most part, Fortran compilers do not check these constraints, so violations can be bugs that are hard to find, but Fortran programmers tend to program in ways that avoid many of these mistakes, and some are easier to find than you might realize. For example, many Fortran programmers follow the convention that functions should be free of side effects and that a subroutine should be used when side effects are desired. Those that do write functions with side effects are extremely careful about affecting other expressions or subexpressions in the same statement because there has never been any guarantee on the order in which these expressions are evaluated, so such a program would be likely not to behave correctly when ported to a new machine or compiler. The aliasing problems show up also in different variations of copy-in/copy-out argument association, independent of optimization level, so a program might have undetected aliasing problems on the first machine it is written on, but such problems are usually detected as it is ported to other machines using other argument association implementations. Kurt W. Hirchert hirchert@ncsa.uiuc.edu National Center for Supercomputing Applications