CVS difference for ais/ai-00255.txt

Differences between 1.2 and version 1.3
Log of other versions for file ais/ai-00255.txt

--- ais/ai-00255.txt	2001/02/13 22:29:22	1.2
+++ ais/ai-00255.txt	2001/09/08 03:35:06	1.3
@@ -1,4 +1,4 @@
-!standard 8.5.1    (05)                               01-02-09  AI95-00255/01
+!standard 8.5.1    (05)                               01-08-31  AI95-00255/02
 !standard 12.4     (09)
 !class binding interpretation 01-02-09
 !status work item 01-02-09
@@ -38,7 +38,7 @@
 In Ada 83, the line marked "Illegal" is clearly illegal by RM83 8.5(5).
 However, there doesn't seem to be a rule in Ada 95 that makes the above illegal.
 
-Is the line marked "Illegal?" illegal? (Yes.) Why? (Tuck said so.)
+Is the line marked "Illegal?" illegal? (Yes.)
 
 !recommendation
 
@@ -50,18 +50,39 @@
 
 !discussion
 
-There is no intent to change the Ada 83 rule here; if there was, it would
-have been documented in the Wording Changes from Ada 83 or Extensions to Ada 83
-sections of the AARM.
+There is no intent to change the Ada 83 rule here. The rule was necessary to
+avoid disappearing components.  Consider the example again, assuming for a
+moment that the declaration of Sx4 is legal:
 
+        type Rec (D : Integer := 1) is
+            record
+                case D is
+                    when 1 =>
+                        F4 : Integer range -10 .. 0;
+                end case;
+            end record;
+
+        subtype Subrec1 is Rec (1);
+
+        generic
+            Sr1 : in out Subrec1;
+        package Genpack is
+            Sx4 : Integer renames Sr1.F4;
+        end Genpack;
+
+        X : Rec;
+        package Inst is new Genpack (X);
+        …
+        X := (D => 2); -- What happened to Inst.Sx4?
+
+The instantiation Inst is legal, because the constraints of the subtype mark
+appearing in the formal_object_declaration don't play a role in parameter
+matching (see RM95 12.4(12)). So even though the nominal subtype of Srl is
+constrained, in an instantiation the corresponding object may be unconstrained.
+
 Moreover, the intent is that object renamings and generic in out objects are
 equivalent (see, for instance, AARM 12.4(1.b)).
 
-Since Ada 95 compilers all implement the Ada 83 rule (as they all of passed
-the ACATS tests in question), and there is no benefit to users to making
-implementors change their compilers in this area, we are reluctant to adopt
-any rule which has that effect.
-
 The best fix to this problem is to define the nominal subtype of a formal
 in out object of a composite type to be unconstrained if the first subtype of
 the type is unconstrained. This change also fixes another, related problem,
@@ -77,23 +98,29 @@
 
 is a similar problem to the renames, and should have a similar resolution.
 
+Note that making the nominal subtype unconstrained doesn't grant additional
+permissions, because the only rule that requires an unconstrained nominal
+subtype is RM95 8.5.1(5), and it doesn't apply here because formal objects are
+never aliased.
+
 !corrigendum 12.04(09)
 
 @drepl
 A @fa<formal_object_declaration> declares a generic formal object. The default
 mode is @b<in>. For a formal object of mode @b<in>, the nominal subtype is the
 one denoted by the @fa<subtype_mark> in the declaration of the formal. For a
-formal object of mode @b<in out>, its type is determined by the @fa<subtype_mark>
-in the declaration; its nominal subtype is nonstatic, even if the
-@fa<subtype_mark> denotes a static subtype.
+formal object of mode @b<in out>, its type is determined by the
+@fa<subtype_mark> in the declaration; its nominal subtype is nonstatic, even
+if the @fa<subtype_mark> denotes a static subtype.
 @dby
 A @fa<formal_object_declaration> declares a generic formal object. The default
 mode is @b<in>. For a formal object of mode @b<in>, the nominal subtype is the
 one denoted by the @fa<subtype_mark> in the declaration of the formal. For a
-formal object of mode @b<in out>, its type is determined by the @fa<subtype_mark>
-in the declaration; its nominal subtype is nonstatic, and, for a composite
-type, is unconstrained if the first subtype of its type is unconstrained, even
-if the @fa<subtype_mark> denotes a constrained or static subtype.
+formal object of mode @b<in out>, its type is determined by the
+@fa<subtype_mark> in the declaration; its nominal subtype is nonstatic, and,
+for a composite type, is unconstrained if the first subtype of its type is
+unconstrained, even if the @fa<subtype_mark> denotes a constrained or static
+subtype.
 
 !ACATS test
 

Questions? Ask the ACAA Technical Agent