comp.lang.ada
 help / color / mirror / Atom feed
From: Shark8 <onewingedshark@gmail.com>
Subject: Possible GNAT problem with aliased parameters.
Date: Fri, 18 Oct 2013 09:01:46 -0700 (PDT)
Date: 2013-10-18T09:01:46-07:00	[thread overview]
Message-ID: <9bc1be39-4377-4df5-8686-786babc756d1@googlegroups.com> (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;


             reply	other threads:[~2013-10-18 16:01 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-18 16:01 Shark8 [this message]
2013-10-18 16:51 ` Possible GNAT problem with aliased parameters 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
replies disabled

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