CVS difference for ais/ai-00229.txt

Differences between 1.16 and version 1.17
Log of other versions for file ais/ai-00229.txt

--- ais/ai-00229.txt	2002/07/23 01:05:23	1.16
+++ ais/ai-00229.txt	2004/11/14 06:36:54	1.17
@@ -1,4 +1,4 @@
-!standard  3.10.2   (32)                             02-05-14  AI95-00229/05
+!standard  3.10.2   (32)                             04-11-10  AI95-00229/06
 !class binding interpretation 00-04-10
 !status Amendment 200Y 02-07-10
 !status WG9 Approved 02-06-21
@@ -66,9 +66,9 @@
 
 Replace the last sentence of RM95 3.10.2(32):
 
-If the subprogram denoted by P is declared within a generic unit,
-and the expression P'Access occurs within the body of that generic
-unit or within the body of a generic unit declared within
+If the subprogram denoted by P is a generic unit or is declared within a
+generic unit, and the expression P'Access occurs within the body of
+that generic unit or within the body of a generic unit declared within
 the declarative region of the generic, then the ultimate ancestor
 of S shall be a non-formal type declared within the generic unit.
 
@@ -223,9 +223,9 @@
 12.3), this rule applies also in the private part of an instance
 of a generic unit. The profile of P shall be subtype-conformant
 with the designated profile of @i<S>, and shall not be Intrinsic.
-If the subprogram denoted by P is declared within a generic unit,
-and the expression P'Access occurs within the body of that generic
-unit or within the body of a generic unit declared within
+If the subprogram denoted by P is a generic unit or is declared within
+a generic unit, and the expression P'Access occurs within the body of
+that generic unit or within the body of a generic unit declared within
 the declarative region of the generic, then the ultimate ancestor
 of @i<S> shall be a non-formal type declared within the generic unit.
 >
@@ -1194,6 +1194,89 @@
 Sent: Tuesday, March 5, 2002  4:13 AM
 
 Good to know that someone on this mailing list is awake ;-).
+
+*************************************************************
+
+!topic Possible deficiency in AI-229?
+!reference AI95-00229
+!from Adam Beneschan 04-10-11
+!discussion
+
+AI-229 makes this illegal:
+
+    procedure Dangle is
+        type Ref is access procedure;
+        P : Ref;
+
+        generic
+        package G is
+            procedure Foo;
+        end G;
+
+        package body G is
+            X : Natural := 0;
+
+            procedure Foo is
+            begin
+                X := X + 1;
+            end Foo;
+        begin
+            P := Foo'Access; -- Legal? (No.)
+        end G;
+
+        procedure Bar is
+            package I is new G; -- Store a reference to I.Foo in P.
+        begin
+            null;
+        end Bar;
+
+    begin
+        Bar;
+        P.all; -- Oops, I.X is gone?
+    end Dangle;
+
+But what about this case?
+
+    procedure Dangle is
+        type Ref is access procedure;
+        P : Ref;
+
+        generic
+            X : in out Integer;
+        procedure Foo;
+
+        procedure Foo is
+        begin
+            P := Foo'Access; -- Legal?
+            X := X + 1;
+        end G;
+
+        procedure Bar is
+            Z : Integer := 0;
+            procedure I is new Foo(Z);    -- sets P := I'Access
+        begin
+            I;
+        end Bar;
+
+    begin
+        Bar;
+        P.all; -- Oops, Bar.Z is gone?
+    end Dangle;
+
+This appears to have the same dangling-reference problem as the first
+example, but the way AI-229 is worded, it doesn't seem to be illegal:
+
+    If the subprogram denoted by P is declared within a generic unit,
+    and the expression P'Access occurs within the body of that generic
+    unit or within the body of a generic unit declared within the
+    declarative region of the generic, then the ultimate ancestor of S
+    shall be a non-formal type declared within the generic unit.
+
+since Foo *is* the generic unit rather than being declared within a
+generic unit.  Offhand, I can't think of any other language rule that
+would make this illegal.
+
+So what have I missed?
 
 *************************************************************
 

Questions? Ask the ACAA Technical Agent