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: dennison@telepath.com Subject: Re: Why a PROGRAM ERROR? Date: 1998/12/11 Message-ID: <74relm$okm$1@nnrp1.dejanews.com>#1/1 X-Deja-AN: 421195737 References: <3670178F.8751F9B9@nowhere.com> X-Http-Proxy: 1.0 x12.dejanews.com:80 (Squid/1.1.22) for client 204.48.27.130 Organization: Deja News - The Leader in Internet Discussion X-Article-Creation-Date: Fri Dec 11 15:44:53 1998 GMT Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.5 [en] (WinNT; I) Date: 1998-12-11T00:00:00+00:00 List-Id: In article , 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. Another very good possibility is that the *actual* parameter passed in was the "'access" of an object, which was declared at a lower scope level than the accesss type used by "Command_Object.The_Object" (which may be My_Class_Object_Type, but we can't tell from this code fragment). I submitted a (slighty more complete :-) ) code fragment here with the exact same problem about 4 months ago... Perhaps Rusnak should submit an expanded fragment that shows the actual call made, as well as the declaration of the actual parameters used, and their enclosing scopes. -- T.E.D. -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own