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, T_FILL_THIS_FORM_SHORT autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,82d521458af23e62,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-03-18 01:56:05 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!news.tele.dk!small.news.tele.dk!130.133.1.3!fu-berlin.de!uni-berlin.de!tar-alcarin.cbb-automation.DE!not-for-mail From: dmitry@elros.cbb-automation.de (Dmitry A. Kazakov) Newsgroups: comp.lang.ada Subject: GNAT error? [a generic child instance looses visibility] Date: Mon, 18 Mar 2002 09:56:03 GMT Message-ID: <3c95b5ad.4844359@News.CIS.DFN.DE> NNTP-Posting-Host: tar-alcarin.cbb-automation.de (212.79.194.111) X-Trace: fu-berlin.de 1016445363 18721666 212.79.194.111 (16 [77047]) X-Newsreader: Forte Free Agent 1.21/32.243 Xref: archiver1.google.com comp.lang.ada:21400 Date: 2002-03-18T09:56:03+00:00 List-Id: The following code results in GNAT compilation error. I tried to reduce the code amount as much as possible: ----------------------------------------------------------------- package Obj is type X is tagged private; private type X is tagged record Component : Integer; -- Visible for children only end record; end Obj; ----------------------------------------------------------------- generic type XX is new X with private; package Obj.Child is type XX_Handle is tagged private; procedure Access_Internals (This : XX_Handle); private type XX_Ptr is access all XX'Class; type XX_Handle is tagged record Ptr : XX_Ptr; end record; end Obj.Child; ----------------------------------------------------------------- package body Obj.Child is procedure Access_Internals (This : XX_Handle) is begin This.Ptr.Component := 0; -- Access the hidden component end Access_Internals; end Obj.Child; ----------------------------------------------------------------- with Obj.Child; package Test is type Y_Handle is private; procedure Crash; private type Y is new Obj.X with null record; type Y_Ptr is access all Y'Class; package Instantiation is new Obj.Child (Y); type Y_Handle is new Instantiation.XX_Handle with null record; end Test; ----------------------------------------------------------------- package body Test is procedure Crash is Var : Y_Handle; begin Access_Internals (Var); end Crash; end Test; ----------------------------------------------------------------- GNAT 3.14p (20010503) Copyright 1992-2001 Free Software Foundation, Inc. Compiling: d:\home\dmitry\new\tests\new_i~eh\test.adb (source file time stamp: 2002-03-18 09:44:16) 1. package body Test is 2. procedure Crash is 3. Var : Y_Handle; 4. begin 5. Access_Internals (Var); 6. end Crash; 7. end Test; ==============Error messages for source file: d:\home\dmitry\new\tests\new_i~eh\test.ads 9. package Instantiation is new Obj.Child (Y); | >>> instantiation error at obj-child.adb:4 >>> no selector "Component" for type "Y'Class" defined at line 7 7 lines: 2 errors It seems that during instantiation Obj.Child.Access_Internals looses access to X.Component, no matter that it belongs to the child package. Object Ada successfully compiles the example above. Also, GNAT's bug? Regards, Dmitry Kazakov