comp.lang.ada
 help / color / mirror / Atom feed
From: Lucretia <laguest9000@googlemail.com>
Subject: Accessibility check failure with Implicit_Dereference aspect
Date: Tue, 12 Aug 2014 10:03:37 -0700 (PDT)
Date: 2014-08-12T10:03:37-07:00	[thread overview]
Message-ID: <3854a5ec-f49a-4c81-916b-e8cf750dc2ad@googlegroups.com> (raw)

Hi,

I've tried this a number of times and still cannot get this thing to work like the documentation (Barnes, Gem's, etc.) say that it's supposed to unless I'm missing something.

I have this:

generic
   type T is new Quicksilver.Containers.Counted_Items.Counted_Item with private;
package Quicksilver.Containers.Smart_Pointers is
   type Access_T is access all T;

   --  Provide an accessor for the counted item that we can return from functions.
   type Reference (Element : not null access T) is limited private with
     Implicit_Dereference => Element;

   --  TODO: Place inside a generic package to constrain the type?
   type Smart_Pointer is new Ada.Finalization.Controlled with private;

   ...

   not overriding
   function Get (Self : in Smart_Pointer) return Reference;
   ...
end Quicksilver.Containers.Smart_Pointers;

On compiling a test, I get the following warnings:

Compiling: /home/laguest/src/mine/sterling-os/quicksilver/unit_tests/test_suite-smart_pointer_tests.adb
Source file time stamp: 2014-08-12 15:21:32
Compiled at: 2014-08-12 17:59:55

==============Error messages for source file: /home/laguest/src/mine/sterling-os/quicksilver/unit_tests/test_suite-smart_pointer_tests.ads
    46.    package Datum_Smart_Pointers is new Quicksilver.Containers.Smart_Pointers (T => Datum);
           |
        >>> warning: in instantiation at quicksilver-containers-smart_pointers.adb:50
        >>> warning: accessibility check failure
        >>> warning: "Program_Error" will be raised at run time
        >>> warning: in instantiation at quicksilver-containers-smart_pointers.adb:67
        >>> warning: accessibility check failure
        >>> warning: "Program_Error" will be raised at run time

 74 lines: No errors, 6 warnings

and the line it's complaining about at line 50 is:

   not overriding
   function Get (Self : in Smart_Pointer) return Reference is
   begin
      --  Keep a copy of the smart pointer inside the reference to stop it from being deallocated.
      return Reference'(Element => Self.Data, Hold => Self);
   end Get;

Specifically the "Element => Self.Data" part.

Has anyone managed to do this?

I've tried with latest GCC trunk, GNAT 4.10.0 20140807 (experimental) and GNAT GPL 2014 and get the same issues.

Is this a compiler issue or me?

Thanks,
Luke A. Guest.

             reply	other threads:[~2014-08-12 17:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-12 17:03 Lucretia [this message]
2014-08-13  9:10 ` Accessibility check failure with Implicit_Dereference aspect Stephen Leake
2014-08-13 18:38   ` Luke A. Guest
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox