comp.lang.ada
 help / color / mirror / Atom feed
* Why a PROGRAM ERROR?
@ 1998-12-10  0:00 Rusnak
  1998-12-11  0:00 ` Matthew Heaney
  0 siblings, 1 reply; 6+ messages in thread
From: Rusnak @ 1998-12-10  0:00 UTC (permalink / raw)


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.

      If you wish to contact me by e-mail my e-mail id is "jrusnak" and
my ISP is "netgate.net".

    Thanks

-John






^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Why a PROGRAM ERROR?
  1998-12-10  0:00 Why a PROGRAM ERROR? Rusnak
@ 1998-12-11  0:00 ` Matthew Heaney
  1998-12-11  0:00   ` dennison
  1998-12-11  0:00   ` Why a PROGRAM ERROR? A GNAT bug? Rusnak
  0 siblings, 2 replies; 6+ messages in thread
From: Matthew Heaney @ 1998-12-11  0:00 UTC (permalink / raw)


Rusnak <bogus@nowhere.com> 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.





^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Why a PROGRAM ERROR?
  1998-12-11  0:00 ` Matthew Heaney
@ 1998-12-11  0:00   ` dennison
  1998-12-11  0:00   ` Why a PROGRAM ERROR? A GNAT bug? Rusnak
  1 sibling, 0 replies; 6+ messages in thread
From: dennison @ 1998-12-11  0:00 UTC (permalink / raw)


In article <m3yaofmpon.fsf@mheaney.ni.net>,
  Matthew Heaney <matthew_heaney@acm.org> wrote:
> Rusnak <bogus@nowhere.com> 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    




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Why a PROGRAM ERROR?  A GNAT bug?
  1998-12-11  0:00 ` Matthew Heaney
  1998-12-11  0:00   ` dennison
@ 1998-12-11  0:00   ` Rusnak
  1998-12-11  0:00     ` dewar
  1998-12-14  0:00     ` Why a PROGRAM ERROR? Robert I. Eachus
  1 sibling, 2 replies; 6+ messages in thread
From: Rusnak @ 1998-12-11  0:00 UTC (permalink / raw)


Matthew Heaney wrote:

> Rusnak <bogus@nowhere.com> 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






^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Why a PROGRAM ERROR? A GNAT bug?
  1998-12-11  0:00   ` Why a PROGRAM ERROR? A GNAT bug? Rusnak
@ 1998-12-11  0:00     ` dewar
  1998-12-14  0:00     ` Why a PROGRAM ERROR? Robert I. Eachus
  1 sibling, 0 replies; 6+ messages in thread
From: dewar @ 1998-12-11  0:00 UTC (permalink / raw)


In article <3671433E.79C04602@nowhere.com>,
  Rusnak <bogus@nowhere.com> wrote:

> I am using a GNAT compiler (i believe the most recent
> one).  Is this
> compiler Ada certified?

Public versions of GNAT are not officially validated (this
is a consequence of the validation policy which requires
that there be a contractual relationship between the user
and the validation agency (among other things this allows
the vendor, in this case ACT, to certify that the version
being used is in fact the validated version. ACT cannot
provide any such assurances for the public version, since
the public version is not in our custody.

GNAT has been validated on a number of targets (it is
indeed the only Ada 95 technology that has been 100%
validated including the core and all annexes, using the
latest ACVC suite), but you must be a customer for the
GNAT Professional product to meet formal validation
requirements. For further information on validated
validated versions of GNAT, contact sales@gnat.com.

Robert Dewar
Ada Core Technologies

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Why a PROGRAM ERROR?
  1998-12-11  0:00   ` Why a PROGRAM ERROR? A GNAT bug? Rusnak
  1998-12-11  0:00     ` dewar
@ 1998-12-14  0:00     ` Robert I. Eachus
  1 sibling, 0 replies; 6+ messages in thread
From: Robert I. Eachus @ 1998-12-14  0:00 UTC (permalink / raw)


In article <3671433E.79C04602@nowhere.com> Rusnak <bogus@nowhere.com> writes:

 >         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.

    Could it be a violation of accessability levels?  The kluge
example changes the accessability level of the value assigned.  (But I
would really have to see more of the code to see if this is the
problem, in particular, the declaration of Command_Object.)



--

					Robert I. Eachus

with Standard_Disclaimer;
use  Standard_Disclaimer;
function Message (Text: in Clever_Ideas) return Better_Ideas is...




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~1998-12-14  0:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-12-10  0:00 Why a PROGRAM ERROR? Rusnak
1998-12-11  0:00 ` Matthew Heaney
1998-12-11  0:00   ` dennison
1998-12-11  0:00   ` Why a PROGRAM ERROR? A GNAT bug? Rusnak
1998-12-11  0:00     ` dewar
1998-12-14  0:00     ` Why a PROGRAM ERROR? Robert I. Eachus

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