!standard 12.05.04 (04) 96-11-16 AI95-00025/02 !class confirmation 95-06-25 !status WG9 approved 96-12-07 !status ARG Approved 9-0-1 96-10-07 !status work item 95-06-25 !status received 95-06-25 !priority Low !difficulty Medium !subject Matching rules for generic formal access-to-constant types !summary 95-06-25 An access-to-variable type cannot be passed as an actual to a generic formal access-to-constant type. !question 95-06-25 RM95-12.5.4(4) states that "If and only if the general_access_modifier constant applies to the formal, the actual shall be an access-to constant type". Is it really intended to forbid an access-to-variable type from being passed as an actual to a generic formal access-to-constant type? (Yes.) !response 95-06-25 Consider the following example: type Actual is access all Integer; X: aliased constant Integer; generic type Formal is access constant Integer; package Gp is function F return Formal; end Gp; package body Gp is function F return Formal is begin return X'Access; end F; end Gp; package Ip is new Gp (Formal => Actual); -- Illegal. If the above were legal, then Ip.F would produce an access-to-variable value designating a constant, thus allowing a constant to be modified. This would be very bad. Hence, the "if and only if" wording of 12.5.4(4). This should be explained in the AARM. !appendix 95-06-25 !section 12.5.4(4) !subject Matching rules for generic formal access-to-constant types !reference RM95-12.5.4(4);5.95 !from Pascal Leroy !reference as: 95-5085.a Pascal Leroy 95-1-25>> !discussion RM95-12.5.4(4) states that "If and only if the general_access_modifier constant applies to the formal, the actual shall be an access-to constant type". This wording (actually, the "if" part) seems to forbid the following text. Is this the intent? I do not understand why this would cause contract model problems, or violate the properties of the type. If there is a hidden reason, it should be stated in the AARM. type Actual is access all Integer; generic type Formal is access constant Integer; package Gp is end Gp; package Ip is new Gp (Formal => Actual); _____________________________________________________________________ Pascal Leroy +33.1.30.12.09.68 pleroy@rational.com +33.1.30.12.09.66 FAX ****************************************************************