CVS difference for ais/ai-00216.txt

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

--- ais/ai-00216.txt	2000/11/28 23:48:08	1.3
+++ ais/ai-00216.txt	2001/10/02 01:27:51	1.4
@@ -1,4 +1,4 @@
-!standard 03.08.01      (01)                        00-11-15  AI95-00216/03
+!standard 03.08.01      (01)                        01-10-01  AI95-00216/04
 !class amendment 99-03-23
 !status work item 99-03-23
 !status received 99-03-23
@@ -23,79 +23,66 @@
 
     pragma Unchecked_Union(first_subtype_mark);
 
-This pragma is intended for use with a type with a variant part
-(potentially with further nested variant parts), that is to be
-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 (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
-a union as its last component.  A variant may have multiple
-components, which would correspond to a C union with a struct
-as one of its elements.  A variant may have a nested variant part,
-which would correspond to a nested C union.  The type may
-have multiple discriminants, to support the possibly
-nested unions being selected along different dimensions.
-
-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
-struct/union, which will be at least the maximum size required for any
-discriminant value.  This is because any whole-object assignments performed
-to or from such an object by the C code will generally involve this maximum
-size, even if they preserve the (conceptual) discriminant value.
-[Note that requiring defaults is not really necessary, but it
-seems benign, and suggests to the reader that objects of such a type
-are always allocated the max size, and are generally "mutable."]
-
-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 (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
-aggregate.
-
-Within the definition of an unchecked_union type, the discriminant(s)
-may not be used in a constraint in a component_definition, unless
-the type of the component is itself an unchecked_union type.  This
-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
-clause.
-
-Outside the definition of the object's type, a discriminant
-of an object of an unchecked_union type must not be read.
-
-Constrained subtypes of an unchecked_union type are permitted,
-as this may be necessary to properly specify the (initial) discriminant
-value for a variable or subcomponent having the type.  It is erroneous to
-perform any operation (in C or Ada) that would have failed a discriminant
-check had the discriminant been present at run-time.
-
-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 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.)
+This pragma is intended for use with a type with a variant part (potentially
+with further nested variant parts), that is to be 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).
+
+The specified type may have a non-variant part preceding the variant part,
+which would correspond to a C struct containing a union as its last component.
+A variant may have multiple components, which would correspond to a C union
+with a struct as one of its elements.  A variant may have a nested variant
+part, which would correspond to a nested C union.  The type may have multiple
+discriminants, to support the possibly nested unions being selected along
+different dimensions.
+
+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 struct/union, which
+will be at least the maximum size required for any discriminant value.  This is
+because any whole-object assignments performed to or from such an object by the
+C code will generally involve this maximum size, even if they preserve the
+(conceptual) discriminant value.
+
+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.
+
+Within the definition of an unchecked_union type, the discriminants may not be
+used in a constraint in a component_definition, unless the type of the
+component is itself an unchecked_union type.  This 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.
+
+Outside the definition of the object's type, a discriminant of an object of an
+unchecked_union type must not be read.
+
+Constrained subtypes of an unchecked_union type are permitted, as this may be
+necessary to properly specify the (initial) discriminant value for a variable
+or subcomponent having the type.  It is erroneous to perform any operation (in
+C or Ada) that would have failed a discriminant check had the discriminant been
+present at run-time.
+
+The pragma Unchecked_Union may be applied to a derived type, presuming it meets
+the requirements for the pragma. 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 discriminants (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
@@ -105,15 +92,18 @@
 
 To avoid other kinds of generic contract violations, if the type is
 non-limited, all of the normal operations of a non-limited type exist,
-including assignment, equality, membership, 'Read, 'Write, 'Input,
-'Output, etc.  Assignment is defined in terms of a block copy on all bits
-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.
+including assignment, equality, membership, 'Read, 'Write, 'Input, 'Output,
+etc.  Assignment is defined in terms of a block copy on all bits 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. No space is
+given for a discriminant; it is illgal to mention a discriminant explicitly in
+a component clause.
+
+An implementation may support this pragma for tagged record types or record
+extensions, with implementation-defined semantics.
 
 !wording
 

Questions? Ask the ACAA Technical Agent