smart compilers

Alex Colvin alexc at dartvax.UUCP
Mon Jan 7 04:05:17 AEST 1985


(intelca.472) mentions what can only be called a horrendous  com-
piler  bug.   That one has been known since roughly FORTRAN II --
namely passing constants by reference.  The solution  adopted  by
most  such  languages  (FORTRAN,PL/I) is to always pass copies of
the constant.

Please understand that the aforementioned compiler is NOT  optim-
izing.  It is compiling incorrect code.

The DTSS PL/I compiler does  the  correct  optimization  in  this
case.  Iff the interprocedure analysis detects that a (reference)
parameter is not modified, then it passes constant  arguments  by
reference,  without  forcing  a copy.  This is done ONLY if it is
known to be safe.

As to passing constants, I see nothing wrong with it.   I  prefer
it  to  passing  variables.  At least with a constant you can see
what you're getting.  True, magic constants (e.g. 501) should  be
given  some sort of explanatory name (e.g. StreetAddress).  But I
see little point in defining ZERO as a name for 0.  Pascal  text-
books  are  particularly  prone to this sort of foolishness.  One
defined NINE as 9. If anything they should have defined it as Ra-
dixLessOne.   That  would  cause  less  surprise  when some idiot
changes it to 7.



More information about the Comp.unix.wizards mailing list