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,1fd537a3da8a5021 X-Google-Attributes: gid103376,public From: Michael Carman Subject: Re: Array access via pointer? Date: 2000/08/02 Message-ID: <39882AE1.23A81345@home.com>#1/1 X-Deja-AN: 653625171 Content-Transfer-Encoding: 7bit References: <398721AD.CAEE3A51@home.com> <_TNh5.1285$nT.135157@news.pacbell.net> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii Organization: None (anarchist) Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 2000-08-02T00:00:00+00:00 List-Id: 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