comp.lang.ada
 help / color / mirror / Atom feed
From: Michael Carman <mjcarman@home.com>
Subject: Re: Array access via pointer?
Date: 2000/08/02
Date: 2000-08-02T00:00:00+00:00	[thread overview]
Message-ID: <39882AE1.23A81345@home.com> (raw)
In-Reply-To: _TNh5.1285$nT.135157@news.pacbell.net

tmoran@bix.com wrote:
> 
> Arr2'Address is the address of Arr2(0).  You are trying to convert
> that to an access value, and not even an access to Arr2(0), but an
> access to Arr2, which isn't the same thing.  So with your unchecked
> conversion, you are telling the compiler that a pointer to an
> element of Arr2, ie a pointer to a System.Address, is a pointer
> to an Addr_Table, an array.  Since Addr_Table is unconstrained,
> the compiler must store the actual bounds somewhere, so it probably
> thinks your pointer points to a bounds dope vector stored at the
> beginning of Arr2, when in fact it points to some System.Address value.

But shouldn't Ada know that if I say Arr2'Address I want a pointer to
the array, not it's first element? Either way, I agree that it's a mess,
which I why I came here appealing for help!
 
>   An Address and an access type are not the same thing, so you are
> crossing your fingers and guessing when you use Unchecked_Conversion.
> Use instead predefined package System.Address_To_Access_Conversions.

Well, no, I wasn't just taking a wild guess. The size and value of the
two types are the same; it's just how Ada thinks of them that's
different. Just for my own sanity, I looked at the body for
System.Address_To_Access_Conversions. To_Pointer() and To_Address() 
are just Unchecked_Conversions (though dressed up a bit with private
types). I thank you though, because using that package will prevent me
from having to declare a bunch of these things myself.

-mjc




  reply	other threads:[~2000-08-02  0:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-08-01  0:00 Array access via pointer? Michael Carman
2000-08-01  0:00 ` Ted Dennison
2000-08-02  0:00   ` Michael Carman
2000-08-03  0:00     ` Ken Garlington
2000-08-03  0:00       ` Robert A Duff
2000-08-03  0:00         ` Ken Garlington
2000-08-04  0:00           ` Robert I. Eachus
2000-08-04  0:00             ` Ken Garlington
2000-08-02  0:00 ` tmoran
2000-08-02  0:00   ` Michael Carman [this message]
2000-08-02  0:00     ` tmoran
2000-08-02  0:00 ` Markku Kotiaho
replies disabled

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