comp.lang.ada
 help / color / mirror / Atom feed
From: cis.ohio-state.edu!math.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.i
Subject: Re: Access before Elaboration (was Re: Odd Generic Behaviour <<LRM Exp erts Whats Going ON??)
Date: 30 Aug 93 07:24:02 GMT	[thread overview]
Message-ID: <1993Aug30.072402.12394@news.eng.convex.com> (raw)

In article <1993Aug27.111311.24900@sei.cmu.edu> jbg@sei.cmu.edu (John Goodenoug
h) writes:
>Although this sounds good at first, the Convex Ada compiler is wrong here,
>because it doesn't raise PROGRAM_ERROR when the generic instantiation is
>elaborated (as pointed out by Sandy Wise).  One might well ask why these pesky
>elaboration errors are defined in the language at all, and this gives a simple
>opportunity to show the language semantics issues.  Consider a modification of
>the original example:
>
> [Code removed]
>
>Note that the elaboration of NEWGEN1's body as part of the elaboration of the
>generic instantiation causes STUFF.TOP to be set to 12 **before** the STUFF
>package has itself been elaborated.  Because of access before elaboration
>checks, the language doesn't define what the value of STUFF.TOP is in the main
>program or what the value of A'LAST is.  It wouldn't surprise me if the Convex
>Ada compiler blew up at compile time or at execution time on this example, but
>even if it doesn't, it is executing an incorrect program whose behavior is not
>defined by the language.

What happend is that the static initialization of stuff.top was done at compile
time, so the value 10 was there when the program started running, and thus
a'last was 10. The the generic body was elaborated, and the value was 12 at
the beginning of the program. I see your point though. If there was a use
of stuff.top later in pack1 spec, it would expect the value to be 10, where
as it would already be 12. 

As a matter of fact, I have just checked the most recent Verdix compiler (6.2)
and this is already fixed, and thus will be picked up for the next Convex
Ada release.

Not a day without learning something :)
-- 
Boris Pelakh		Ada Project Leader          pelakh@convex.com
		     Convex Computer Corporation
"If winning isn't important, why keep score ?"	-- Lt. Worf, Star Trek TNG.
			

                 reply	other threads:[~1993-08-30  7:24 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox