comp.lang.ada
 help / color / mirror / Atom feed
* using 'address to make indrect calls
@ 1999-06-29  0:00 Raymond C. Rawa
  1999-06-30  0:00 ` Pascal MALAISE
  1999-07-01  0:00 ` Robert A Duff
  0 siblings, 2 replies; 7+ messages in thread
From: Raymond C. Rawa @ 1999-06-29  0:00 UTC (permalink / raw)


I'm getting a scary warning message from VADSself for SPARC Solaris 2.3,
Version 6.2 when I compile the example below.

Can someone please explain what is meant by an "uplevel reference"?  And
when I should be concerned?

Thanks,
Raymond C. Rawa


***********************************  test.a 
***********************************

   1:generic 
   2:package G_PKG is
   3:end G_PKG;
   4:
   5:with system;
   6:package body G_PKG is
   7:   procedure a is
   8:      loc : SYSTEM.Address;
   9:   begin
  10:      loc := a'Address;
  11:   end a;
  12:end G_PKG;
  13:
  14:with G_PKG;
  15:procedure test is
  16:   package g is new G_PKG;
A --------------^
A:warning: using this address to make an indirect call may produce
unpredictable results if the subprogram makes uplevel references.
A:warning:	at line: 10 column: 14 within generic g_pkg in file:
/MV22/system/rawa/jass_3.2/jass_stubs.ss/dev.wrk/test/test.a
  17:begin
  18:   null;
  19:end test;




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

* Re: using 'address to make indrect calls
  1999-06-30  0:00 ` Pascal MALAISE
@ 1999-06-30  0:00   ` Robert Dewar
  1999-07-01  0:00   ` Raymond C. Rawa
  1 sibling, 0 replies; 7+ messages in thread
From: Robert Dewar @ 1999-06-30  0:00 UTC (permalink / raw)


In article <377A5A93.AB271D47@magic.fr>,
  Pascal MALAISE <malaise@magic.fr> wrote:
> The instanciation in make within a procedure/function.
> The validity of the instanciated objects ends when the
> procedure ends.

This is probably a misleading response, the warning message
was about up level references not about subprogram lifetime.
The two are related but quite different issues.

Of course the right advice in any case is to contact the vendor
to get an exact description of what the warning means, and how
it should be handled.



Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.




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

* Re: using 'address to make indrect calls
  1999-06-29  0:00 using 'address to make indrect calls Raymond C. Rawa
@ 1999-06-30  0:00 ` Pascal MALAISE
  1999-06-30  0:00   ` Robert Dewar
  1999-07-01  0:00   ` Raymond C. Rawa
  1999-07-01  0:00 ` Robert A Duff
  1 sibling, 2 replies; 7+ messages in thread
From: Pascal MALAISE @ 1999-06-30  0:00 UTC (permalink / raw)


"Raymond C. Rawa" wrote:
>    1:generic
>    2:package G_PKG is
>    3:end G_PKG;

>   14:with G_PKG;
>   15:procedure test is
>   16:   package g is new G_PKG;
> A --------------^
> A:warning: using this address to make an indirect call may produce
> unpredictable results if the subprogram makes uplevel references.
> A:warning:      at line: 10 column: 14 within generic g_pkg in file:
> /MV22/system/rawa/jass_3.2/jass_stubs.ss/dev.wrk/test/test.a

The instanciation in make within a procedure/function.
The validity of the instanciated objects ends when the procedure ends.
Suppose G_PKG declares objects (variables, procedures) and test stores
the address of such object in a "global", remanent variable (in a
package spec):
other_package.g_object_address := g.object'address
the using other_package.g_object_address after the end of g leeds to
unpredicable result.
The compiler does not know that test is your main procedure. Neither do
I,
but I suppose, and in this case (test is the "main") there is no danger.

If you want to get rid of the warning:
with G_PKG;
package g is new G_PKG;

with g;
procedure test is


Then the instanciation is more "static".

-- 
Pascal MALAISE
(priv) mailto:malaise@magic.fr
(prof) mailto:malaise@fr.airsysatm.thomson-csf.com




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

* Re: using 'address to make indrect calls
  1999-06-29  0:00 using 'address to make indrect calls Raymond C. Rawa
  1999-06-30  0:00 ` Pascal MALAISE
@ 1999-07-01  0:00 ` Robert A Duff
  1999-07-01  0:00   ` Dale Stanbrough
  1 sibling, 1 reply; 7+ messages in thread
From: Robert A Duff @ 1999-07-01  0:00 UTC (permalink / raw)


"Raymond C. Rawa" <rcr@b.com> writes:

> Can someone please explain what is meant by an "uplevel reference"?
...

An up-level reference is when a procedure refers to an object declared
outside of that procedure.

- Bob
-- 
Change robert to bob to get my real email address.  Sorry.




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

* Re: using 'address to make indrect calls
  1999-06-30  0:00 ` Pascal MALAISE
  1999-06-30  0:00   ` Robert Dewar
@ 1999-07-01  0:00   ` Raymond C. Rawa
  1 sibling, 0 replies; 7+ messages in thread
From: Raymond C. Rawa @ 1999-07-01  0:00 UTC (permalink / raw)


Pascal MALAISE wrote:

> The instanciation in make within a procedure/function.
> The validity of the instanciated objects ends when the procedure ends.
> Suppose G_PKG declares objects (variables, procedures) and test stores
> the address of such object in a "global", remanent variable (in a
> package spec):
> other_package.g_object_address := g.object'address
> the using other_package.g_object_address after the end of g leeds to
> unpredicable result.
> The compiler does not know that test is your main procedure. Neither do
> I,
> but I suppose, and in this case (test is the "main") there is no danger.
> 
> If you want to get rid of the warning:
> with G_PKG;
> package g is new G_PKG;
> 
> with g;
> procedure test is
> 
> Then the instanciation is more "static".

Thank you, for your help.  Your solution worked like a charm for the
test case.

Alas, the test case I proposed is too simplistic.  In my actual
application, the generic package is instantiated within a package body,
not a procedure.


Here's what I'm really trying to do...  

(1) I've got a task out there that receives procedure addresses and
attempts to execute them in it's thread of control.
(2) I've got a bunch of packages out there that send callback procedure
addresses to the task.


The first two seem to work just fine, here's the complication...

(3) Some packages need to pass a parameter to the callback routines. 
The task only handles parameterless procedures.
(4) So I've created a generic package that can be instanciated with the
desired parameter type.  It contains two procedures.

procedure Call_Procedure_With_Parameter(
   Procedure_Address : SYSTEM.Address;
   Parameter         : Parameter_Type;
-- places Procedure_Address  and Parameter into a queue.
-- passes Call_Queued_Procedure'address to the above mentioned task.

procedure Call_Queued_Procedure;
-- pop's an address and parameter off the queue
-- executes the procedure located at Procedure_Address with Parameter

(5) Now any package that needs to pass parameters to it's callback
routine can simply instanciate my generic with the desired type and
execute the Call_Procedure_With_Parameter routine.

My problem seems to be that the compiler doesn't know that the procedure
address specified in the generic package is valid, so it produces a
warning message.

I guess as long as I instanciate the generic package at either the
library level or within a package or procedure that is elaborated at the
library level I'm fine.  I just wish I could supress that darn warning.



Raymond C. Rawa
V-22 Operational Software IPT
Digital Map Software Designer
Raymond.C.Rawa@Boeing.com

Oh by the way, I'm stuck in Ada83




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

* Re: using 'address to make indrect calls
  1999-07-01  0:00 ` Robert A Duff
@ 1999-07-01  0:00   ` Dale Stanbrough
  1999-07-02  0:00     ` Robert A Duff
  0 siblings, 1 reply; 7+ messages in thread
From: Dale Stanbrough @ 1999-07-01  0:00 UTC (permalink / raw)


Robert A Duff wrote:

" An up-level reference is when a procedure refers to an object declared
  outside of that procedure."


Is that the case even for package based variables/static in C?


Dale




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

* Re: using 'address to make indrect calls
  1999-07-01  0:00   ` Dale Stanbrough
@ 1999-07-02  0:00     ` Robert A Duff
  0 siblings, 0 replies; 7+ messages in thread
From: Robert A Duff @ 1999-07-02  0:00 UTC (permalink / raw)


dale@cs.rmit.edu.au (Dale Stanbrough) writes:

> Robert A Duff wrote:
> 
> " An up-level reference is when a procedure refers to an object declared
>   outside of that procedure."
> 
> 
> Is that the case even for package based variables/static in C?

Well, I'm not sure if that should be called an uplevel ref or not.
Probably not.  It's certainly not usually implemented the same way.
OTOH, you can view this as just an optimization of the bottom-most
stack frame of the environment task.

- Bob
-- 
Change robert to bob to get my real email address.  Sorry.




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

end of thread, other threads:[~1999-07-02  0:00 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-06-29  0:00 using 'address to make indrect calls Raymond C. Rawa
1999-06-30  0:00 ` Pascal MALAISE
1999-06-30  0:00   ` Robert Dewar
1999-07-01  0:00   ` Raymond C. Rawa
1999-07-01  0:00 ` Robert A Duff
1999-07-01  0:00   ` Dale Stanbrough
1999-07-02  0:00     ` Robert A Duff

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