From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Date: 26 Aug 93 23:07:18 GMT From: dog.ee.lbl.gov!agate!howland.reston.ans.net!noc.near.net!nic.umass.edu!ym ir.cs.umass.edu!rcfnews!sandy@ucbvax.Berkeley.EDU (Sandy Wise) Subject: Re: Odd Generic Behaviour < List-Id: BERRYMAN@orca.drep.dnd.ca (DON BERRYMAN) writes: I have discovered an odd behavour of ADA when I attempt to specify and use a generic package inside a package specification (Pack1, code and audit of compilation follow). Not being an LRM expert this looked like a reasonable package specification, and both the Alsys/Hp & Dec/Vax compilers accepted it with out a single error. So I assume that the code will work (except for my stupid logic errors). With Alsys/Hp the code links fine but blows up with a PROGRAM_ERROR before executing a single line of code. None of the TEXT_IO.PUT_LINES gets executed. All I get is a trace pointing into PACK1. Welcome the mysterious world of elaboration order... LRM 11.1 indicates that "PROGRAM_ERROR is raised upon an attempt [...] to elaborate a generic instatiation, if the body of the corresponding unit has not yet been elaborated." LRM 10.5 requires that a spec be elaborated before any entity that with's it and that a spec be elaborated before its body. But does not place any requirements on the elaboration order of bodies except that they must be elaborated before the program starts. So. The problem here is that you are violating LRM 11.1 since the body of GEN1 is not elaborated at the time of instantiation. Moreover, the body of GEN1 is nested inside PACK1 and cannot have been elaborated yet since that would require the elaboration of the body of PACK1 before the elaboration of GEN1 (forbidden by 10.5). Move GEN1 outside of PACK1. The header to PACK1 becomes: with GEN1; pragma ELABORATE (GEN1); -- ensure the body of GEN1 is elaborated -- before use... package PACK1 is ... /s -- Alexander Erskine Wise /\/\/\/\/\/\/\/\/\/\/\/\ Software Development Laboratory /\/\/\/\/\/\/\/\/\/\/\/\/\/\ WISE@CS.UMASS.EDU /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ \/\/\ This situation calls for large amounts of unadulterated CHOCOLATE! /\/\/\