comp.lang.ada
 help / color / mirror / Atom feed
From: "Robert I. Eachus" <rieachus@comcast.net>
Subject: Re: [announcement] SYSAPI and SYSSVC for Windows
Date: Sun, 21 Dec 2003 19:50:38 -0500
Date: 2003-12-21T19:50:38-05:00	[thread overview]
Message-ID: <eu6dnR0AqaR9onui4p2dnA@comcast.com> (raw)
In-Reply-To: <bs4ncu$51v$1@online.de>

Ekkehard Morgenstern wrote:

> "Michal Morawski" <morawski@zsk.p.lodz.pl> wrote:
> 
>>Try:
>>       O.B := O.A(1)'Unchecked_Access; -- This is OK, A(i) are aliased
>>'Access does not work because in the procedure You are getting address of
>>the variable (may be) on the stack
> 
> 
> Yup, unchecked access works (compiles).
> 
> thanks! :)

This is exactly the sort of thing that Unchecked_Access is provided for. 
  You can tell that wherever you can see O.B, O.A must also exist. 
(Even though those names may be long gone.)  At first though, I thought 
that there was a bug here.  There is nothing wrong in general with the 
assignment.  The reason for the error had to do with accessibility 
levels of parameters.  If O is not a parameter:

  procedure ttest2 is
     type Integer_Array is array (Integer range <>) of aliased Integer;
     type Integer_Access is access all Integer;
     type T is limited record
        A : Integer_Array (1..3);
        B : Integer_Access;
     end record;

     O : T;

     procedure F is
     begin
      O.B := O.A(1)'Access; -- This is OK, A(i) are aliased
     end;

  begin
    F;
  end ttest2;

gnatmake ttest2
gcc -c ttest2.adb
gnatbind -x ttest2.ali
gnatlink ttest2.ali

Everything is fine in this case, since the static accessibility levels 
match.  As for the original ttest0, at first I thought it should be 
legal, but there would be a run-time check that could raise 
Program_Error.  (The problem is incidently is not the assignment of the 
access value to O.B, it is taking O.A(1)'Access.) RM 3.10.2(29) says: 
"A check is made that the accessibility level of X is not deeper than 
that of the access type A. If this check fails, Program_Error is raised."

But there is also paragraph RM 3.10.2(28): "The accessibility level of 
the view shall not be statically deeper than that of the access type 
A..."  The static accessability level of the VIEW O.A(1) is that of F:
3.10.2(7): "A parameter of a master has the same accessibility level as 
the master."

So for the first example, there is a legality check, and it is 
independent of the accessiblity level of the object actually passed as a 
parameter to F.  Aren't you glad that 'Unchecked_Access exists for cases 
like this, where you can figure that the access value is safe, even if 
the compiler can't?  Or where it is harder to figure out if the compiler 
will allow it than to prove it safe?

-- 
                                           Robert I. Eachus

"The war on terror is a different kind of war, waged capture by capture, 
cell by cell, and victory by victory. Our security is assured by our 
perseverance and by our sure belief in the success of liberty." -- 
George W. Bush




  reply	other threads:[~2003-12-22  0:50 UTC|newest]

Thread overview: 67+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-12-17 19:17 [announcement] SYSAPI and SYSSVC for Windows amado.alves
2003-12-17 19:56 ` Georg Bauhaus
2003-12-18  9:08 ` Dmitry A. Kazakov
2003-12-18 12:14   ` Ekkehard Morgenstern
2003-12-18 13:31     ` Georg Bauhaus
2003-12-19 10:45       ` Ekkehard Morgenstern
2003-12-19 17:12         ` Georg Bauhaus
2003-12-19 17:22           ` Vinzent 'Gadget' Hoefler
2003-12-20  0:21           ` Ekkehard Morgenstern
2003-12-20  2:18             ` Georg Bauhaus
2003-12-20  4:40               ` Ekkehard Morgenstern
2003-12-21  3:45                 ` Georg Bauhaus
2003-12-21 19:01                   ` Piracy was " Robert I. Eachus
2003-12-18 14:32     ` Dmitry A. Kazakov
2003-12-19 11:11       ` Ekkehard Morgenstern
2003-12-19 15:15         ` Hyman Rosen
2003-12-19 15:50           ` Ekkehard Morgenstern
2003-12-19 16:48             ` Hyman Rosen
2003-12-19 16:57               ` Hyman Rosen
2003-12-20  1:17               ` Ekkehard Morgenstern
2003-12-21  2:19                 ` Hyman Rosen
2003-12-21 10:34                   ` Ekkehard Morgenstern
2003-12-22  9:02                     ` Hyman Rosen
2003-12-22 15:17                       ` Ekkehard Morgenstern
2003-12-22 15:08                     ` Hyman Rosen
2003-12-22 15:31                       ` Ekkehard Morgenstern
2003-12-22 16:35                         ` Ekkehard Morgenstern
2003-12-23  1:47                           ` Hyman Rosen
2003-12-23  8:40                             ` Ekkehard Morgenstern
2003-12-23  9:05                               ` Stephen Leake
2003-12-19 17:06         ` Dmitry A. Kazakov
2003-12-20  1:49           ` Ekkehard Morgenstern
2003-12-20 11:13             ` Dmitry A. Kazakov
2003-12-20 13:40               ` Ekkehard Morgenstern
2003-12-20 17:21                 ` Dmitry A. Kazakov
2003-12-20 19:52                   ` Ekkehard Morgenstern
2003-12-21  4:24                     ` Georg Bauhaus
2003-12-21 13:42                     ` Dmitry A. Kazakov
2003-12-21 15:48                       ` Ekkehard Morgenstern
2003-12-21 17:46                         ` Michal Morawski
2003-12-21 18:05                           ` Ekkehard Morgenstern
2003-12-22  0:50                             ` Robert I. Eachus [this message]
2003-12-23 23:02                       ` Robert A Duff
2003-12-24 11:20                         ` Dmitry A. Kazakov
2003-12-24 16:57                           ` Robert A Duff
2003-12-25 14:00                             ` Dmitry A. Kazakov
2003-12-28  1:49                       ` Dave Thompson
  -- strict thread matches above, loose matches on Subject: below --
2003-12-15 14:18 Ekkehard Morgenstern
2003-12-15 15:10 ` Ekkehard Morgenstern
2003-12-15 17:10 ` Jeffrey Carter
2003-12-15 18:38   ` Ekkehard Morgenstern
2003-12-16  0:25     ` Stephen Leake
2003-12-16  0:56       ` Ekkehard Morgenstern
2003-12-16  2:47         ` Ludovic Brenta
2003-12-16 17:45           ` Ekkehard Morgenstern
2003-12-16 19:54             ` Ludovic Brenta
2003-12-16 22:09               ` Ekkehard Morgenstern
2003-12-17 15:24                 ` Ludovic Brenta
2003-12-17 23:23                   ` Ekkehard Morgenstern
2003-12-19 18:14                   ` Warren W. Gay VE3WWG
2003-12-16  5:36         ` tmoran
2003-12-16 17:30           ` Ekkehard Morgenstern
2003-12-15 20:44 ` David Marceau
2003-12-16  0:34   ` Ekkehard Morgenstern
2003-12-17 12:05 ` Dmitry A. Kazakov
2003-12-17 15:00   ` Ekkehard Morgenstern
2003-12-20 19:24 ` Ekkehard Morgenstern
replies disabled

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