CVS difference for ai05s/ai05-0164-1.txt
--- ai05s/ai05-0164-1.txt 2009/10/22 04:25:37 1.1
+++ ai05s/ai05-0164-1.txt 2009/10/23 06:06:31 1.2
@@ -1,4 +1,4 @@
-!standard 3.4(xx) 09-10-21 AI05-0164-1/01
+!standard 3.4(18/2) 09-10-21 AI05-0164-1/01
!standard 6.1(27.1/2)
!class binding interpretation 09-10-21
!status work item 09-10-21
@@ -237,6 +237,73 @@
the overriding procedure Pack2.Op is called, and that procedure thinks it's
calling a function that returns something of type T1 when it isn't. This cannot
be good.
+
+****************************************************************
+
+From: Christoph Grein
+Sent: Wednesday, June 24, 2009 2:37 AM
+
+ overriding
+ procedure Op (Obj : in out T1;
+ Count : in Integer;
+ Func : access function (Obj : in T1) return T1);
+
+GNAT Pro 6.2.1 says: subprogram Op is not overriding.
+
+This is accepted as overriding, but it leads of course to problems in the body:
+
+ procedure Op (Obj : in out T1;
+ Count: in Integer;
+ Func : access function (Obj: in Pack_0.Root) return Pack_0.Root);
+
+****************************************************************
+
+From: Adam Beneschan
+Sent: Wednesday, June 24, 2009 9:40 AM
+
+> overriding
+> procedure Op (Obj : in out T1;
+> Count : in Integer;
+> Func : access function (Obj : in T1) return T1);
+>
+> GNAT Pro 6.2.1 says: subprogram Op is not overriding.
+
+I'm not surprised. I'm guessing that T1 is derived from Root, and GNAT
+implicitly declares the subprogram inherited from this one:
+
+ procedure Op (Obj : in out Root;
+ Count : in Integer;
+ Func : access function (Obj : in Root) return Root);
+
+it replaces "Root" by "T1" in the profile, but when doing so, it fails to go
+into the profile of the access-subprogram parameter, resulting in this inherited
+subprogram:
+
+ procedure Op (Obj : in out T1;
+ Count : in Integer;
+ Func : access function (Obj : in Root) return Root);
+
+So then of course it would reject the above declaration as "overriding" (and
+accept this one:)
+
+
+> This is accepted as overriding, but it leads of course to problems in
+> the body:
+>
+> procedure Op (Obj : in out T1;
+> Count: in Integer;
+> Func : access function (Obj: in Pack_0.Root) return
+> Pack_0.Root);
+
+Our compiler has the same behavior.
+
+However, I believe GNAT (like our compiler) is doing the wrong thing, based on the
+wording of the RM. It could be that the wording of the RM doesn't reflect what is
+intended, and that "systematically replacing subtypes of the profile" isn't supposed
+to include subtypes in an access-subprogram-parameter profile. If that's the case,
+the RM needs to be changed, and then GNAT will be right without making any changes.
+But as it currently stands, unless there is some other applicable rule I missed, the
+compilers are not following the RM.
****************************************************************
Questions? Ask the ACAA Technical Agent