Computer bugs from many years ago

Computer bugs from the 1960s and 1970s

By Jacob Palme

In the 1960s and the beginning of the 1970s, I was mostly using the Fortran programming language. Here are some stories of weird things which happened using the IBM Fortran G and Fortran H compilers.

Optimize a little too much?
I wrote a Fortran program containing the following statement:

  IF <I.EQ.I/100*100> WRITE...

The idea with this code was that the WRITE statement would be executed only for every 100th iteration of the loop. Since I/100*100, using integer arithmetic, will only be equal to I if I is a multiple of 100.

This worked all right with the normal Fortran G compiler. But when we got the new, super-duper highly optimizing Fortran H compiler, the WRITE statement started executing for every iteration in the loop, instead of every 100th!

It is not too difficult to guess what the optimizing compiler did with this code!

2+2=6
And here is how I found out that 2+2=6.

I wrote the following FORTRAN function:

  FUNCTION F(I)
  I=I+1
  END

This function was then called from another subroutine with the following call:

  F(2)
  I=2+2

And the value of I after this piece of code was not 4 but 6!

Again, I leave it to the reader to guess what had happended.

More about famous computer bugs.