-- RM 4.6(21,23.1):
--
--If there is a type that is an ancestor of both the target type and the
--operand type, or both types are class-wide types, then at least one of
--the following rules shall apply:
--
--    ...
--
--    -- The operand and target types shall both be class-wide types and
--       the specific type associated with at least one of them shall be
--       an interface type.

with ada.finalization;
package pak1 is
   pragma elaborate_body;
   type T1 is interface;

   type T2 is new ada.finalization.Controlled with null record;
end pak1;

package body pak1 is
   procedure p1(x1: T1'Class) is
   x2: T2'class := T2'class(x1);
   begin
       null;
   end p1;
end pak1;

gnatmake -gnat05 pak1
gcc-4.1 -c -gnat05 pak1.adb
pak1.adb:4:22: invalid tagged conversion, not compatible with type "T1'class"
defined at pak1.ads:16

See also 4.6(23.c/2) in the AARM. A run-time check is needed at this point.


-- 
           Summary: Legal program rejected, explicit type conversion between
                    two unrelated class-wide types, RM 4.6(21/2,23.1/2)
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: ada
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ludovic at ludovic-brenta dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34510

Reply via email to