comp.lang.ada
 help / color / mirror / Atom feed
* Pointer help
@ 1992-04-16 18:52 iggy.GW.Vitalink.COM!psinntp!psinntp!vitro.com!v7.vitro.com!eswgcc
  0 siblings, 0 replies; 4+ messages in thread
From: iggy.GW.Vitalink.COM!psinntp!psinntp!vitro.com!v7.vitro.com!eswgcc @ 1992-04-16 18:52 UTC (permalink / raw)


	Can anyone tell me any way to get a pointer to point to a declared data
item rather than an allocated location?   Perhaps with a 'ADDRESS?   Does this 
require UNCHECKED_CONVERSION:), or what?

		Thanks,  Carmen

-- 
         ______________________________________________________________________
        /  Carmen Castells-Schofield             Internet: carmencs@vitro.com
__     /   Vitro Corporation	                 Voice:    (301) 231-2187
  \   /    14000 Georgia Ave.              ....................................
   \ /     Silver Spring, MD 20906-2972    : May the light within us all    
    *                                      : answer each the other's call
                                           :...................................
*******************************************************************************
*   Any opinions expressed herein are my own property, not those of whoever   *
*            happens to be holding my paycheck at the moment.                 *
*******************************************************************************

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

* Re: Pointer help
@ 1992-04-16 20:59 dog.ee.lbl.gov!overload.lbl.gov!agate!spool.mu.edu!wupost!usc!rpi!sarah!c
  0 siblings, 0 replies; 4+ messages in thread
From: dog.ee.lbl.gov!overload.lbl.gov!agate!spool.mu.edu!wupost!usc!rpi!sarah!c @ 1992-04-16 20:59 UTC (permalink / raw)


In article <1992Apr16.135211.144@v7.vitro.com>, carmencs@vitro.com (Carmen Cast
ells-Schofield) writes:
> 
> 	Can anyone tell me any way to get a pointer to point to a declared data
> item rather than an allocated location?   Perhaps with a 'ADDRESS?   Does thi
s 
> require UNCHECKED_CONVERSION:), or what?

Since I happen to know you're running on a VAX, I'll answer for that platform.

Try page 2-22 of the Run Time Reference Manual.  Basically, you can use
an Unchecked_Conversion, but to be safe, the access type must access a
record type.  It is unclear from that reference whether the operand of
the 'ADDRESS attribute must also be a record type.  From the LRM, section
13.7.2, however, it seems clear that the result of the 'ADDRESS attribute
reliably indicates the location of a data item (rather than a descriptor
thereof) and no such restriction should exist.

Since the Run Time manual contains an example on page 10-2 of using
Unchecked_Conversion between a pointer to an integer and an integer
variable 'ADDRESS, it seems unlikely you would have problems with
scalars.  Clearly, arrays and especially unconstrained arrays would need
to be encapsulated in records.

	John Briggs			vaxs09@v7.vitro.com

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

* Re: Pointer help
@ 1992-04-20 15:42 David Emery
  0 siblings, 0 replies; 4+ messages in thread
From: David Emery @ 1992-04-20 15:42 UTC (permalink / raw)


Briggs' solution is, of course, specific to the DEC Vax compiler.  This
is an issue addressed by Ada9X (if it made the 'cut').  In general,
addresses and access values are not the same, and unchecked
conversions between them can cause very serious portability problems.

The URG is currently studying the issue of access to address
conversions, but we have no specific recommendation yet.

				dave

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

* Re: Pointer help
@ 1992-04-27 16:39 sun-barr!cs.utexas.edu!usc!rpi!bu.edu!inmet!inmet!spock!stt
  0 siblings, 0 replies; 4+ messages in thread
From: sun-barr!cs.utexas.edu!usc!rpi!bu.edu!inmet!inmet!spock!stt @ 1992-04-27 16:39 UTC (permalink / raw)


Re: Creating an access value designating a declared object.

As Dave Emery suggests, in the proposed Ada 9X revision,
one may create an access value designating a declared object
using the ACCESS attribute, but only if the object is marked 
"aliased" in its declaration.  (This feature did "make the cut" 
through the various rounds of simplification.)  

Here is a simple example:

    type Rec_Type is record ... end record;

    type Ptr_Type is access all Rec_Type;  -- the "all" indicates that
                                           -- this is a "general" access
                                           -- type that is allowed to
                                           -- point at "aliased" declared
                                           -- objects

    R : aliased Rec_Type;    -- Here is an object that may be pointed-to
                             -- (because it is marked aliased).
    X : Ptr_Type := R'ACCESS;  -- Declare a pointer and initialize it
                               -- to point at R.

Using 'ADDRESS and unchecked conversion works in most, but not
all Ada 83 compilers.  It fails in compilers where access types
are shorter than full addresses (e.g. on the 1750A with expanded
memory, the Rational, and some 80x86 compilers).  Vendors often
provide some alternative approach if the unchecked conversion
approach won't work.

The Ada 9X approach requires both that the access type be special
(i.e. marked as a "general" access type with the keyword "all"),
and that the designated object be special (i.e. marked with "aliased").
This is intended to preserve upward compatibility of efficiency,
so that non-general access types may still be shorter than full
addresses, and non-aliased objects may be allocated in registers rather
than real memory.  In addition, an optimizer "knows" that only
aliased objects can be affected by stores through general access values.

The keyword "aliased" may also appear on record component declarations
and on the component subtype indication for an array type, to allow
pointers to designate aliased components of composite objects.

-S. Tucker Taft
Ada 9X Mapping/Revision Team (ada9x-mrt@inmet.com)
Intermetrics, Inc.
Cambridge, MA  02138

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

end of thread, other threads:[~1992-04-27 16:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1992-04-27 16:39 Pointer help sun-barr!cs.utexas.edu!usc!rpi!bu.edu!inmet!inmet!spock!stt
  -- strict thread matches above, loose matches on Subject: below --
1992-04-20 15:42 David Emery
1992-04-16 20:59 dog.ee.lbl.gov!overload.lbl.gov!agate!spool.mu.edu!wupost!usc!rpi!sarah!c
1992-04-16 18:52 iggy.GW.Vitalink.COM!psinntp!psinntp!vitro.com!v7.vitro.com!eswgcc

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