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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,3e5147bcbe0e25dc X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!t69g2000cwt.googlegroups.com!not-for-mail From: "Adam Beneschan" Newsgroups: comp.lang.ada Subject: Re: Access to interface conversion problem Date: 13 Mar 2007 09:54:19 -0700 Organization: http://groups.google.com Message-ID: <1173804859.568512.327160@t69g2000cwt.googlegroups.com> References: <1173799509.497206.119820@q40g2000cwq.googlegroups.com> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" X-Trace: posting.google.com 1173804865 6828 127.0.0.1 (13 Mar 2007 16:54:25 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 13 Mar 2007 16:54:25 +0000 (UTC) In-Reply-To: User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.12) Gecko/20050922 Fedora/1.7.12-1.3.1,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: t69g2000cwt.googlegroups.com; posting-host=66.126.103.122; posting-account=cw1zeQwAAABOY2vF_g6V_9cdsyY_wV9w Xref: g2news1.google.com comp.lang.ada:14520 Date: 2007-03-13T09:54:19-07:00 List-Id: On Mar 13, 9:06 am, Robert A Duff wrote: > msimoni...@power.com.pl writes: > > The output of this program is two addresses, the first one 4 less than > > the second one (in my original program the difference is 12). > > Removing the Root_Implementation_Type tagged type from inheritance > > hierarchy results in identical addresses. > > > The question is: > > Am I doing something wrong with the conversion? > > I don't know (I didn't read your code carefully), but it is normal for > access values pointing at the same object to be represented by different > addresses, depending on which interface you are viewing the object as. > This is because C++ works that way, and GNAT mimics the C++ conventions > in order to make interfacing Ada with C++ easier. I still think 'Address should be the same, though. The definition of X'Address for an object X is that it is "the address of the first of the storage elements allocated to X"; and here, after IFace_Ptr has been converted from Object_Ptr by a legal type conversion, IFace_Ptr.all and Object_Ptr.all are the same object, so their 'Address should be the same. It may be the case that IFace_Ptr and Object_Ptr are represented as different addresses in memory, and that if you used an Unchecked_Conversion on the access objects themselves, you might see different values. But Marcin's code didn't use Unchecked_Conversion; the 'Addresses should be the same, and if the addresses stored in memory are different, the compiler needs to adjust for this when computing 'Address. This definitely seems like a compiler bug. -- Adam