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=3.8 required=5.0 tests=BAYES_00,INVALID_MSGID, RATWARE_MS_HASH,RATWARE_OUTLOOK_NONAME autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,62ea712965950abb X-Google-Attributes: gid103376,public From: "Troy Noble" Subject: Re: Ada tagged types not as powerful as C++ for dispatching??? Date: 1997/08/18 Message-ID: <01bcab6a$f2061820$92165da6@csp3610x>#1/1 X-Deja-AN: 264865309 References: <33F4D31F.6E511B93@mci.com> Organization: home Newsgroups: comp.lang.ada Date: 1997-08-18T00:00:00+00:00 List-Id: Jon, I'm using GNAT 3.09 on Linux and on Win32. I got the same results in both places. The fact that you got it to work caused me to go back and take another look. What I uncovered may or may not be a bug in GNAT, but I'm not sure I know Ada95 well enough to make that call. See what you think... The only difference between what you tried and what I tried is that in my message on this newsgroup I put the definition of Circle_Ptr INSIDE package Figures. In my non-working code I had defined Circle_Ptr INSIDE my procedure Test_Figures. Apparently GNAT was getting confused when trying to resolve the accessibility levels between the "locally" scoped Circle_Ptr definition and the "package" scoped Figure_Ptr definition, or else what I did was just plain wrong. In short, I moved the line: type Circle_Ptr is access all Circle; from inside procedure Test_Figures to inside package Figures... and everything works fine now. I can create Circle's and use Figure_Ptr or Circle_Ptr to "point" to them, then I can convert back-n-forth between Figure_Ptr and Circle_Ptr as desired. Much nice... and works as I'd expect for my OO dispatching purposes. Thanks very much for testing this and answering my question. Do you think this is a bug in GNAT that I should report, or was it in fact detecting the error properly? Thanks again, Troy Jon S Anthony wrote in article ... > In article <33F4D31F.6E511B93@mci.com> Troy Noble writes: > > > A_Figure := Figures.Figure_Ptr(C2_Ptr); > > -- previous line: operand has deeper accessibility level than target > > This does not look correct. Neither the access types nor the object > decls have different access levels. The following works fine under > both gnat305 and gnat309 (both sparc.solaris) > > with Figures; use Figures; > procedure Fig_Test is > C2_Ptr : Circle_Ptr; > A_Figure: Figures.Figure_Ptr; > begin > A_Figure := new Figures.Circle; -- line (1) > C2_Ptr := Circle_Ptr(A_Figure); -- line (2) > C2_Ptr := new Figures.Circle; > A_Figure := Figure_Ptr(C2_Ptr); > end; > > > What compiler are you using? > > /Jon > -- > Jon Anthony > OMI, Belmont, MA 02178, 617.484.3383 > "Nightmares - Ha! The way my life's been going lately, > Who'd notice?" -- Londo Mollari >