CVS difference for ais/ai-00344.txt
--- ais/ai-00344.txt 2004/12/09 19:55:31 1.14
+++ ais/ai-00344.txt 2005/01/07 03:07:41 1.15
@@ -3084,3 +3084,76 @@
****************************************************************
+From: Randy Brukardt
+Sent: Friday, December 9, 2004 7:25 PM
+
+In writing up the AARM notes for 3.9, I'm beginning to wonder if the definition
+of tags is quite right. The new text of 3.9(4) says:
+
+ The tag of a specific tagged type identifies the full_type_declaration of
+ the type, and for a type extension, is sufficient to uniquely identify
+ the type among all descendants of the same ancestor. If a declaration for
+ a tagged type occurs within a generic_package_declaration, then the
+ corresponding type declarations in distinct instances of the generic
+ package are associated with distinct tags. For a tagged type that is
+ local to a generic package body and with any ancestors also local to
+ the generic body , the language does not specify whether repeated
+ instantiations of the generic body result in distinct tags.
+
+We also have 3.9(26), which gives a permission to raise Tag_Error for tags that
+refer to types that don't exist in the permission. But there is no permission
+to give the wrong answer for a tag representing a type that no longer exists.
+That suggests that "=" could give the wrong answer based on this wording.
+
+Consider:
+
+ procedure Test is
+ T1, T2 : Ada.Tags.Tag;
+
+ function Get_It return Ada.Tags.Tag is
+ type Test_Type is new Ada.Finalization.Controlled with null record;
+ begin
+ return Test_Type'Tag;
+ end Get_It;
+ begin
+ T1 := Get_It;
+ T2 := Get_It;
+ if T1 = T2 then
+ Put_Line ("Violates 3.9(4)! Different type's tags are equal");
+ end if;
+ exception
+ when Tag_Error => null; -- OK, Tag error raised.
+ end Test;
+
+In a typical implementation, the tag would be augmented with a pointer to the
+stack frame of Get_It. And it is very likely that those frames would be the
+same in these two calls. Thus the tags would be identical. The implementation
+could hardly raise Tag_Error in that case, and thus it would get the wrong
+answer.
+
+The implementation could use a serial number to keep the tags different, but
+that would require three word tags (it couldn't be stored at the point of the
+type definition, or it would match in the example above).
+
+This certainly seems to be a pathology that we don't want to make work
+right. It seems to me that the wording of 3.9(4) is a bit too strong. We're
+really only concerned about types that actually exist. (We already gave up in
+streaming going further than that, it seems that should extend to all types.) I
+was going to add a To Be Honest note, but perhaps it needs more than that.
+
+Changing the wording to:
+
+ "...for a type extension, is sufficient to uniquely identify
+ the type among all descendants that currently exist of the same
+ ancestor. ..."
+
+would do the trick.
+
+Should this be a To Be Honest, or should we change the wording?
+
+[Private e-mail discussion decided to use a To Be Honest AARM Note
+rather than changing the wording. I've recorded my mail so that we have
+a record of the pathological example that motivated it. - RLB]
+
+****************************************************************
+
Questions? Ask the ACAA Technical Agent