Non-erroneous operations preserve undefined component values AI-00489/05 1 90-12-13 ra WA | !standard 03.02.01 (18) 90-12-13 AI-00489/05 !class ramification 86-10-13 | !status WG9-approved 90-12-07 !status ARG-approved 90-05-28 (reviewed) !status ARG-approved (10-0-1) 89-10-25 (pending editorial review) !status work-item 89-07-10 !status received 86-10-13 !references 83-00825, 83-00981 !topic Non-erroneous operations preserve undefined component values !summary 90-04-20 A scalar subcomponent with an undefined value is only considered to have a defined value if a defined value is assigned to it. !question 90-04-20 3.2.1(18) says: If the operand of a type conversion or qualified expression is a variable that has scalar subcomponents with undefined values, then the values of the corresponding subcomponents of the result are undefined. Is this not also true for other operations as well, e.g., assignment, construction of an aggregate, construction of a slice, selection of a record component, indexing of an array, etc.? For example, consider: subtype LINE is STRING (1..80); type PAGE is array (1..60) of LINE; type DOCUMENT is record TITLE : LINE; TEXT : PAGE; end record; LINE1 : LINE; UNDEF_LINE : LINE; UNDEF_PAGE : PAGE; UNDEF_DOC : DOCUMENT; ... LINE1 := UNDEF_LINE; -- array assignment TEXT_IO.PUT (LINE1); -- parameter association UNDEF_PAGE := (1..60 => UNDEF_LINE); -- aggregate UNDEF_PAGE (11..20) := LINE1(1..10); -- slice UNDEF_PAGE := UNDEF_DOC.TEXT; -- selection UNDEF_LINE := UNDEF_PAGE(15); -- indexing Isn't it necessary for the rule in 3.2.1(18) to be extended to these operations as well? Non-erroneous operations preserve undefined component values AI-00489/05 2 90-12-13 ra WA !response 89-07-10 For assignment statements, 5.2(3) says: Finally, the value of the expression becomes the new value of the variable. This means that when the value of an expression contains subcomponents with undefined values, the corresponding subcomponents of the target variable are similarly undefined. Hence, after the assignment of UNDEF_LINE to LINE1, any attempt to evaluate LINE1(1) makes the execution of the program erroneous. Similarly, for subprogram parameter associations when the parameter has a composite type, the value of a formal parameter is determined by copy or by reference (6.2(7)). Hence, if a subcomponent of an actual parameter has an undefined value, the corresponding subcomponent of the formal parameter has an undefined value, and if no value is assigned to the subcomponent during the execution of the subprogram (or entry), the corresponding subcomponent still has an undefined value after completion of the call. Similarly, for an aggregate, each component association associates the value of its expression with the corresponding components. When the component expression has subcomponents with undefined values, the corresponding subcomponents of the aggregate's value similarly have undefined values. Similar reasoning applies for slices, selection from a record object, and indexing. Actually, the cited sentence in 3.2.1(18) is not really needed, since the conversion and qualification operations have no effect on subcomponents, and hence, do not affect whether their value is defined or not.