comp.lang.ada
 help / color / mirror / Atom feed
* Possible GNAT problem with aliased parameters.
@ 2013-10-18 16:01 Shark8
  2013-10-18 16:51 ` sbelmont700
  0 siblings, 1 reply; 11+ messages in thread
From: Shark8 @ 2013-10-18 16:01 UTC (permalink / raw)


The Ada 2012 Rational says the following about Aliased parameters:

>    The other change in Ada 2012 concerning parameters is that they may be
>    explicitly marked aliased thus procedure P(X: aliased in out T; ... );
>    As a consequence within P we can write X'Access.

Yet, when such parameters are thus used (X'Access) the compiler generates the following message "access-to-variable designates constant" and fails the compilation.

-- Example:
-----------

    Package Test is
        Type Maze(<>) is tagged private;
        
        None : Aliased Constant Maze;
        
        Function Create( North, South, East, West : Aliased Maze'Class:= None )
          return Maze;
        
        
    Private
        
        Type Paths is Array(Positive range <>) of Access Maze'Class;
          
        Type Maze( Length : Natural ) is tagged record
            Exits : Paths(1..Length);
        end record;
        
        -- Note: Expression-function used so everything is defined in-spec.
        Function Create( North, South, East, West : Aliased Maze'Class:= None )
          return Maze is
          ( Maze'(Length => 4, Exits => (North'Access, South'Access, East'Access, West'Access)) );
          
          None : Aliased Constant Maze := ( Length => 0, Others => <> );
        
    End Test;


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

end of thread, other threads:[~2013-10-21  0:55 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-18 16:01 Possible GNAT problem with aliased parameters Shark8
2013-10-18 16:51 ` sbelmont700
2013-10-19  1:59   ` Randy Brukardt
2013-10-19  5:48     ` Shark8
2013-10-19  7:48       ` Dmitry A. Kazakov
2013-10-19 14:30       ` sbelmont700
2013-10-19 21:17         ` Shark8
2013-10-20  6:29           ` Shark8
2013-10-20 15:33             ` sbelmont700
2013-10-21  0:29               ` Shark8
2013-10-21  0:55                 ` sbelmont700

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