CVS difference for ais/ai-00216.txt
--- ais/ai-00216.txt 1999/10/07 00:25:07 1.2
+++ ais/ai-00216.txt 2000/11/28 23:48:08 1.3
@@ -1,4 +1,4 @@
-!standard 03.08.01 (01) 99-09-30 AI95-00216/02
+!standard 03.08.01 (01) 00-11-15 AI95-00216/03
!class amendment 99-03-23
!status work item 99-03-23
!status received 99-03-23
@@ -28,9 +28,10 @@
manipulated in C using union(s). The pragma
specifies that the associated type should be given
a representation that leaves no space for the discriminant(s)
-of the type. Furthermore, the effect of this pragma includes an implicit
-suppress of Discriminant_Check on the specified type, and an implicit
-convention of C (which may be overridden).
+of the type (unless overridden by a component clause that specifies
+a location for the discriminant). Furthermore, the effect of this pragma
+includes an implicit suppress of Discriminant_Check on the specified type,
+and an implicit convention of C (which may be overridden).
The specified type may have a non-variant part preceding the
variant part, which would correspond to a C struct containing
@@ -41,7 +42,7 @@
have multiple discriminants, to support the possibly
nested unions being selected along different dimensions.
-The Ada type must have defaults for all discriminants.
+The Ada type may, but need not, have defaults for all discriminants.
All objects of the type, even if limited or allocated in the heap
(and hence effectively constrained by the initial discriminant value(s)),
should be allocated the size C would allocate for the corresponding
@@ -55,9 +56,10 @@
Each discriminant of an object of an unchecked_union type
must be specified (explicitly or implicitly) when the object is created,
-even though its value is not stored, to enable appropriate default
-initialization of the appropriate variant(s), or to determine which fields
-should appear in a record aggregate.
+even though its value is not stored (unless a location is specified via a
+component clause), to enable appropriate default initialization of the
+appropriate variant(s), or to determine which fields should appear in a record
Within the definition of an unchecked_union type, the discriminant(s)
may not be used in a constraint in a component_definition, unless
@@ -65,7 +67,8 @@
is to ensure that the size of the component does not depend on the
value of the discriminant. Note that the discriminant may be used
to govern a discriminant part, or as a default initial value for
+a component, or within a component clause of a record representation
Outside the definition of the object's type, a discriminant
of an object of an unchecked_union type must not be read.
@@ -78,10 +81,21 @@
The pragma Unchecked_Union may be applied to a derived type,
presuming its ultimate ancestor type meets the requirements for the pragma.
-Converting the derived type to an ancestor (checked) type raises
-Program_Error. Converting from an ancestor (checked) type to the derived
+Converting the derived type to an unconstrained subtype of
+an ancestor (checked) type raises Program_Error, because there is
+no way to determine the values for the discriminants.
+Converting to a constrained subtype is permitted, as the
+discriminant values are implied by the constraint (as above,
+the conversion is erroneous if it would have failed a discriminant check).
+Converting from an ancestor (checked) type to the derived
type is permitted, and simply drops the discriminant(s) (and performs
whatever other representation adjustments are necessary).
+If the target (unchecked) subtype is constrained, a constraint check
+is performed on the value of the checked type prior to dropping the
+discriminants. (These conversion rules are intended to allow
+an Ada program to primarily manipulate a checked type, and then
+convert to/from an unchecked type just before and after communicating
+with C code.)
In an instantiation of a generic, so as to avoid contract violations involving
discriminant references in the body of the generic, if the actual type is an
@@ -96,6 +110,10 @@
of the representation. The other operations all raise Program_Error,
because they generally require reading the value of the discriminant
to give a meaningful result.
+Record representation clauses are permitted for unchecked unions.
+By default, no space is given for a discriminant unless it
+is mentioned explicitly in a component clause.
Questions? Ask the ACAA Technical Agent