Version 1.1 of ai05s/ai05-0029-1.txt

Unformatted version of ai05s/ai05-0029-1.txt version 1.1
Other versions for file ai05s/ai05-0029-1.txt

!standard 12.5(8)          06-11-13 AI05-0029-1/01
!class binding interpretation 06-11-13
!status work item 06-11-13
!status received 06-06-02
!priority Medium
!difficulty Easy
!qualifier Omission
!subject Meaning of 12.5(8)
!summary
TBD.
!question
Consider the following code:
package Q is type T is limited private; private type T is range 1 .. 10; end Q;
generic type A is array (Positive range <>) of T; package Q.G is A1, A2 : A (1 .. 1); private B : Boolean := A1 = A2; end Q.G;
with Q.G; package R is type C is array (Positive range <>) of Q.T;
package I is new Q.G (C); -- Where is the predefined "=" for C? end R;
Observe that type T is limited, but not "really" limited, so its partial view doesn't have an "=" operator but of course its full view does. Observe also that Q.G is a public child of Q, so the formal type A is limited in the formal part and visible part of the generic, but at the beginning of the private part of Q.G we discover that T is actually nonlimited, and an "=" for A is declared (7.3.1(3)). Therefore, the call to this "=" in the private part of Q.G is legal.
Now the nasty part is the instantiation I in R. The actual type C has no "=" operator, because there is no place where its component type is nonlimited. So it is very much unclear what is the interpretation of the "=" operator in the private part of I. The relevant text in the RM appears to be the penultimate sentence of 12.5(8), which says "In an instance, the copy of such an implicit declaration declares a view of the predefined operator of the actual type, even if this operator has been overridden for the actual type". But since the actual type has no predefined "=", that rule doesn't seem to help.
What happens here?
!recommendation
(See Summary.)
!wording
TBD.
!discussion
--!corrigendum A.18.2(239/2)
!ACATS test
!appendix

From: Pascal Leroy
Date: Friday, June 2, 2006  1:50 AM

I am in the process of revamping our implementation of inherited
subprograms, and I am running into an oddity on which I would like to have
the opinion of the assembled experts.  Consider the following code:

package Q is
    type T is limited private;
private
    type T is range 1 .. 10;
end Q;

generic
    type A is array (Positive range <>) of T;
package Q.G is
    A1, A2 : A (1 .. 1);
private
    B : Boolean := A1 = A2;
end Q.G;

with Q.G;
package R is
    type C is array (Positive range <>) of Q.T;

    package I is new Q.G (C); -- Where is the predefined "=" for C?
end R;

Observe that type T is limited, but not "really" limited, so its partial
view doesn't have an "=" operator but of course its full view does.
Observe also that Q.G is a public child of Q, so the formal type A is
limited in the formal part and visible part of the generic, but at the
beginning of the private part of Q.G we discover that T is actually
nonlimited, and an "=" for A is declared (7.3.1(3)).  Therefore, the call
to this "=" in the private part of Q.G is legal.

Now the nasty part is the instantiation I in R.  The actual type C has no
"=" operator, because there is no place where its component type is
nonlimited.  So it is very much unclear what is the interpretation of the
"=" operator in the private part of I.  The relevant text in the RM
appears to be the penultimate sentence of 12.5(8), which says "In an
instance, the copy of such an implicit declaration declares a view of the
predefined operator of the actual type, even if this operator has been
overridden for the actual type".  But since the actual type has no
predefined "=", that rule doesn't seem to help.

Is an implementation expected to conjure up an "=" operator for C (and
hide it under the rug) just in case it were used in such an instantiation?
That would be disgggusting.

****************************************************************

From: Tucker Taft
Date: Friday, June 2, 2006  1:54 PM

The part that says "even if this operator has been
overridden for the actual type" is pretty much just
a non-normative clause.  The key thing is that a
predefined operator is provided, independent of what
the actual type has (or doesn't have).

Operator "reemergence" in a generic is pretty well known,
but perhaps you are right that operator "emergence" is
less well known.

****************************************************************

From: Robert A. Duff
Date: Friday, June 2, 2006  3:58 PM

> Is an implementation expected to conjure up an "=" operator for C (and
> hide it under the rug) just in case it were used in such an instantiation?
> That would be disgggusting.

I would spell it deeesgusting.  ;-)

Sounds like a nasty (but obscure) hole in the language (predefined "=" is
declared in certain places, and referred to in other places, but it's not
declared-where-used in this case).

For what it's worth, GNAT doesn't get that far.  It gives an error on the
generic Q.G:

q-g.ads:7:23: there is no applicable operator "=" for type "A" defined at line 3

on the line:

    B : Boolean := A1 = A2;

****************************************************************

Questions? Ask the ACAA Technical Agent