comp.lang.ada
 help / color / mirror / Atom feed
* Accessibility check failure with Implicit_Dereference aspect
@ 2014-08-12 17:03 Lucretia
  2014-08-13  9:10 ` Stephen Leake
  0 siblings, 1 reply; 3+ messages in thread
From: Lucretia @ 2014-08-12 17:03 UTC (permalink / 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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-08-13 18:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-12 17:03 Accessibility check failure with Implicit_Dereference aspect Lucretia
2014-08-13  9:10 ` Stephen Leake
2014-08-13 18:38   ` Luke A. Guest

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