[comp.lang.ada] Optimizing out elaborations

linnig@skvax1.csc.ti.COM (10/14/88)

 Fred Hosch <fred@cs.utexas.EDU> writes:

> It's not clear to me that LRM 11.6(7) permits the compiler to optimize
> away the declaration elaboration.  If K were a variable subsequently
> assigned, the "predefined operation" of assignment "need not be invoked."
> I think a CONSTRAINT_ERROR or NUMERIC_ERROR is required to be raised
> in this case?

Imagine the following program segment:
        
	count: integer := 0;
	function counter return integer;

	a: constant integer := counter;
	b: constant integer := counter;	
	c: constant integer := counter;
	
	function counter return integer is
	begin count := count +1;
	  return count;
	end;
	...

I sure would expect A and C to get 1 and 3 respectively; even if the
compiler optimized away the variable B.

	Mike Linnig,
	Texas Instruments