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=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,3f74d676465455d2 X-Google-Attributes: gid103376,public From: Rusnak Subject: Re: Why a PROGRAM ERROR? A GNAT bug? Date: 1998/12/11 Message-ID: <3671433E.79C04602@nowhere.com>#1/1 X-Deja-AN: 421228455 Content-Transfer-Encoding: 7bit References: <3670178F.8751F9B9@nowhere.com> Content-Type: text/plain; charset=us-ascii Organization: Lockheed Martin Missiles and Space Company, Sunnyvale, Ca. Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 1998-12-11T00:00:00+00:00 List-Id: Matthew Heaney wrote: > Rusnak writes: > > > I have the following code in a generic package (or code similar to it > > anyway): > > > > > > Given a tagged type "My_Instance" and a type defined as > > > > type My_Class_Object_Type is access all My_Instance'Class; > > > > I have a function in the spec/body, defined in the body as > > > > function Unpack(The_Object : access My_Instance'Class) > > Core_Text : String) > > return Command_Object > > is > > Return_Value : Command_Object; > > begin > > . . . > > Command_Object.The_Object := > > My_Class_Object_Type(The_Object); > > . . . > > end Unpack; > > > > > > Any time I try to cast the anonymous access type to > > My_Instance'Class to the type My_Class_Object_Type, > > a program error is raised. Why is this the case, why is the > > error not caught at compile time, and how can I resolve > > the error? It seems to only occur when a cast like this one is > > made inside an instantiation of a generic package. > > > > Any help is greatly appreciated. > > Is it possible that you're following a path that doesn't include a > return statement (because of an internal exception, perhaps)? If you're > getting Program_Error when you execute a function, that's usually the > reason. No such path. The same error also occurs within a procedure. I believe this could be a GNAT compiler bug having to deal with a generic (which is actually within a generic). The code DOES allow me to do the following: function Unpack(The_Object : access My_Instance'Class) Core_Text : String) return Command_Object is Return_Value : Command_Object; type Cluge_My_Class_Object_Type is access My_Instance'Class; begin . . . Command_Object.The_Object := Cluge_My_Class_Object_Type(The_Object); . . . end Unpack; without raising a program error! Thus, if I define a 'Class type local to the function definition, I can cast it without problem, but if it is defined anywhere outside the function body, I get a PROGRAM ERROR. I have had to put a cluge in the code for now to decalre a local type and an unchecked conversion from that type to the one defined externally, but I don't like having to do this. I am using a GNAT compiler (i believe the most recent one). Is this compiler Ada certified? I could be wrong on all of this, but it seems too strange that the above code allows me to do the cast but the previous one did not. Input is again always appreciated. -John e-mail "jrusnak" at the IP address "netgate.net" if you like