[comp.sys.sgi] f77 -O bug

finnd%vax.runit.unit.uninett@NAC.NO (Finn Drablos) (08/17/89)

I have a fortran program where file names are made in several steps, mainly
in order to create unique file names. The following short test program
shows how it is done.

==================

      program string
c  Short program to test -O optimization in f77
      character*25 line
      character*10 name
c
      i0 = ichar('0')
      i = 1
      name = 'filename'
      iend = 8
c
      line = 'FILE '//name(1:iend)//'.ext.'//char(i0+i)
      write(*,*) line
      stop
      end


==================

If I compile this program with f77, the output is 'FILE filename.ext.1'.
However, if I use f77 -O the output is 'FILE filename.ext.', and my
filename is not unique. Of course, the solution is to compile without
the -O option. I don't know if I trust the global optimization
any more ....

==================

Finn Drablos                 PHONE +47 7 597710        FAX +47 7 597708
MR-Senteret, SINTEF          MHS(EAN)    : finnd@vax.runit.unit.uninett
N-7034 TRONDHEIM, NORWAY     EARN/BITNET : drabloes@norunit
-----------------------------------------------------------------------

==================