comp.lang.ada
 help / color / mirror / Atom feed
* Odd/Broken behavior DOTNET-GNAT vs GNAT regarding tagged types.
@ 2010-10-22  3:35 Shark8
  2010-10-22  8:01 ` Georg Bauhaus
  2010-10-22 16:22 ` Adam Beneschan
  0 siblings, 2 replies; 7+ messages in thread
From: Shark8 @ 2010-10-22  3:35 UTC (permalink / 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.



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-10-25 15:34 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-22  3:35 Odd/Broken behavior DOTNET-GNAT vs GNAT regarding tagged types Shark8
2010-10-22  8:01 ` 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

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