From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.7 required=5.0 tests=BAYES_00,INVALID_DATE, MSGID_SHORT,REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!dciem!nrcaer!scs!spl1!laidbak!att!pacbell!ames!ncar!gatech!udel!rochester!pt.cs.cmu.edu!sei!sei.cmu.edu!firth From: firth@sei.cmu.edu (Robert Firth) Newsgroups: comp.lang.ada Subject: Re: Dynamic Address Clauses?? Message-ID: <5697@aw.sei.cmu.edu> Date: 2 Jun 88 12:39:30 GMT Article-I.D.: aw.5697 References: <8806011944.AA06549@ti.com> Sender: netnews@sei.cmu.edu Reply-To: firth@bd.sei.cmu.edu.UUCP (Robert Firth) Organization: Carnegie-Mellon University, SEI, Pgh, Pa List-Id: In article <8806011944.AA06549@ti.com> LINNIG@eg.csc.ti.COM (Mike Linnig) writes: >Folks, > >The following package was compiled with two compilers (DEC Ada and >Tartan 1750a Ada). Both allowed the declaration of X. DEC ada >complained about the type conversion used for the rep clause >in ANOTHER. >Assuming one or both is legal, what do they mean??? Wow! Yes, both address clauses are legal according to the RM [13.5], which requires a "simple expression" yielding a value of type ADDRESS. Note particularly that the RM does NOT require a static expression! However, the second simple expression - stupid(x) - is not portable. It assumes that INTEGER and ADDRESS are interconvertible, which will be so only if ADDRESS is a numeric type. Evidently it is on the one machine and not on the other. Finally, there is a problem here - there is a reference to the value in X when X in fact has no value. The program is therefore "erroneous", by RM [3.2.1 (17,18)] And what does it "mean"? I've commented the code to show what I think it means. ------------------------------------------------------------ with SYSTEM; use SYSTEM; package DYNAMIC_ADDR is subtype STUPID is SYSTEM.ADDRESS; function DYNAMIC return STUPID; -- just some function X: INTEGER; for X use at DYNAMIC; -- just what does this mean?? -- [RF] call the function DYNAMIC. The return value -- is the address of X. The implementation will -- probably declare a hidden pointer and then -- reference X indirectly through it ANOTHER: INTEGER; for ANOTHER USE AT stupid(x); -- [RF] similarly, fetch the value of X (NOT its address) -- convert that value to an address, and put ANOTHER -- there. Again, this probably means building a -- hidden pointer -- I guess we can use x as a pointer -- but is it only evaluated at package elaboration? -- [RF] the code I'd expect to see: -- declare space for 2 pointers (REFX and REFANOTHER) -- call DYNAMIC -- store return value in REFX -- fetch value of X (ie load indirect through REFX) -- store that value in REFANOTHER end DYNAMIC_ADDR;