comp.lang.ada
 help / color / mirror / Atom feed
From: Shark8 <onewingedshark@gmail.com>
Subject: Odd/Broken behavior DOTNET-GNAT vs GNAT regarding tagged types.
Date: Thu, 21 Oct 2010 20:35:59 -0700 (PDT)
Date: 2010-10-21T20:35:59-07:00	[thread overview]
Message-ID: <512951a6-bcc3-4c1a-a5ce-5bd3402d7143@j25g2000yqa.googlegroups.com> (raw)

Hey everyone; I just got bit with a bit of a surprise regarding the
differences in how tagged types are treated by GNAT vs DOTNET-GNAT,
The output of 'external_tag shows why the behavior of the Ada.Tags
Package is broken under DOTNET.

Here's the source for replicating. {I'm still using the 2009 Gnat/
DOTNET-Gnat.}


-- Package with tagged types.
----------------------------------------------
Package Tagged_Base_Pkg is
   Type Tagged_Base is Tagged Null Record;

   Type Tagged_Child is New Tagged_Base_Pkg.Tagged_Base with Record
      Some_Data : Integer:= Positive'First;
   End Record;

End Tagged_Base_Pkg;

-- Program source to replicate
----------------------------------------------
With
Ada.Tags,
Ada.Text_IO,
Tagged_Base_Pkg;

Procedure Tag_Error is
   Use Tagged_Base_Pkg;

   SubType Parent_Class is Tagged_Base'Class;
   SubType Child_Class is Tagged_Child'Class;


   A_Parent : Parent_Class:=	Tagged_Base'( Others => <> );
   A_Child  : Child_Class:=	Tagged_Child'( Others => <> );


   Use Ada.Text_IO, Ada.Tags;
Begin
   Put_Line( "External tag for base type: "
            & Tagged_Base'External_Tag
           );
   Put_Line("External tag for child type: "
            & Tagged_Child'External_Tag
           );
   Put_Line( "" );
   Put( "Tagged child is " );
   If NOT Is_Descendant_At_Same_Level
     (	Descendant => A_Child'Tag,
	Ancestor   => A_Parent'Tag
     ) then
      Put("NOT ");
   end if;

   put_line( "a decendant." );

End Tag_Error;

---------------------------------------------------------------


-- .NET output
----------------------
C:\PROGRA~3\TEMPOR~1\testing>tag_error.exe
External tag for base type: tagged_base_pkg.tagged_base
External tag for child type: tagged_base_pkg.tagged_child

Tagged child is NOT a decendant.

-- Native output
----------------------
C:\PROGRA~3\TEMPOR~1\testing>tag_error.exe
External tag for base type: TAGGED_BASE_PKG.TAGGED_BASE
External tag for child type: TAGGED_BASE_PKG.TAGGED_CHILD

Tagged child is a decendant.



             reply	other threads:[~2010-10-22  3:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-22  3:35 Shark8 [this message]
2010-10-22  8:01 ` Odd/Broken behavior DOTNET-GNAT vs GNAT regarding tagged types Georg Bauhaus
2010-10-22 16:22 ` Adam Beneschan
2010-10-22 19:58   ` Shark8
2010-10-22 23:20     ` Adam Beneschan
2010-10-23  1:57       ` Shark8
2010-10-25 15:34         ` Adam Beneschan
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox