From: "Adam Beneschan" <adam@irvine.com>
Subject: Re: Access to interface conversion problem
Date: 13 Mar 2007 09:54:19 -0700
Date: 2007-03-13T09:54:19-07:00 [thread overview]
Message-ID: <1173804859.568512.327160@t69g2000cwt.googlegroups.com> (raw)
In-Reply-To: <wccird5p1qo.fsf@shell01.TheWorld.com>
On Mar 13, 9:06 am, Robert A Duff <bobd...@shell01.TheWorld.com>
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
next prev parent reply other threads:[~2007-03-13 16:54 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-13 15:25 Access to interface conversion problem msimonides
2007-03-13 16:06 ` Robert A Duff
2007-03-13 16:54 ` Adam Beneschan [this message]
2007-03-13 17:35 ` Robert A Duff
2007-03-13 20:56 ` Simon Wright
2007-03-13 22:32 ` Adam Beneschan
2007-03-14 9:06 ` msimonides
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox