Path: utzoo!attcan!uunet!lll-winken!lll-tis!helios.ee.lbl.gov!pasteur!ucbvax!skvax1.csc.ti.COM!linnig
From: linnig@skvax1.csc.ti.COM (Mike Linnig)
Newsgroups: comp.lang.ada
Subject: over ambitious optimizers
Message-ID: <8806241657.AA23329@ti.com>
Date: 24 Jun 88 16:48:42 GMT
Sender: daemon@ucbvax.BERKELEY.EDU
Organization: The Internet
Lines: 26

Folks,

I compiled the following procedure and discovered that the validated
compiler I was using had optimized away the first assignment of I. I was
really testing something else, but should it have deleted that assignemnt?

I can imagine that the function SOMEINT actually used the value of I in
it's calculation (it would be in the scope of I).

Is this an over ambitious optimizer?

	Mike Linnig,
	Texas Instruments

----------------------------------------------------------------------
PROCEDURE leftside(i: IN OUT integer) IS

TYPE myarray  IS ARRAY(integer RANGE 1..15) OF integer;
anarray: myarray;

FUNCTION someint RETURN integer IS SEPARATE;

BEGIN
  I := 5;	-- OPTIMIZED AWAY !
  anarray(someint) := 3;
  i := 7;
END;