* 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
* Re: Odd/Broken behavior DOTNET-GNAT vs GNAT regarding tagged types.
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
1 sibling, 0 replies; 7+ messages in thread
From: Georg Bauhaus @ 2010-10-22 8:01 UTC (permalink / raw)
On 10/22/10 5:35 AM, Shark8 wrote:
> -- Package with tagged types.
> End Tagged_Base_Pkg;
>
> -- Program source to replicate
> ----------------------------------------------
> With
> Ada.Tags,
> Ada.Text_IO,
> Tagged_Base_Pkg;
>
> Procedure Tag_Error is
gcc -c -gnat05 -gnatwa tag_error.adb
+===========================GNAT BUG DETECTED==============================+
| GPL 2010 (20100603) (x86_64-apple-darwin9.6.0) GCC error: |
| in gnat_to_gnu_entity, at ada/gcc-interface/decl.c:634 |
| Error detected at tbp.ada:26:40 |
| Please submit a bug report by email to
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Odd/Broken behavior DOTNET-GNAT vs GNAT regarding tagged types.
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
1 sibling, 1 reply; 7+ messages in thread
From: Adam Beneschan @ 2010-10-22 16:22 UTC (permalink / raw)
On Oct 21, 8:35 pm, Shark8 <onewingedsh...@gmail.com> wrote:
> 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.
Not sure what you're trying to do here, or why this is causing a
problem. The RM says that the default 'External_Tag is implementation-
defined, so you shouldn't depend on it being a certain value, or else
you should write your own "for Tagged_Base'External_Tag use ..."
clause. My apologies if you already knew this and had some other
reason for being surprised.
-- Adam
[snip]
> -- .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
* Re: Odd/Broken behavior DOTNET-GNAT vs GNAT regarding tagged types.
2010-10-22 16:22 ` Adam Beneschan
@ 2010-10-22 19:58 ` Shark8
2010-10-22 23:20 ` Adam Beneschan
0 siblings, 1 reply; 7+ messages in thread
From: Shark8 @ 2010-10-22 19:58 UTC (permalink / raw)
On Oct 22, 10:22 am, Adam Beneschan <a...@irvine.com> wrote:
> On Oct 21, 8:35 pm, Shark8 <onewingedsh...@gmail.com> wrote:
>
> > 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.
>
> Not sure what you're trying to do here, or why this is causing a
> problem. The RM says that the default 'External_Tag is implementation-
> defined, so you shouldn't depend on it being a certain value, or else
> you should write your own "for Tagged_Base'External_Tag use ..."
> clause. My apologies if you already knew this and had some other
> reason for being surprised.
>
> -- Adam
>
> [snip]
>
> > -- .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.
>
>
Ah, the only reason there's an 'External_Tag reference is for output
onscreen display {lazy shortcutting of
Ada.Tags.External_Tag(Item'Tag), which should give the same thing};
the real oddity is the behavior of Is_Descendant_At_Same_Level which
doesn't readily appear to use the external formatting of the tag.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Odd/Broken behavior DOTNET-GNAT vs GNAT regarding tagged types.
2010-10-22 19:58 ` Shark8
@ 2010-10-22 23:20 ` Adam Beneschan
2010-10-23 1:57 ` Shark8
0 siblings, 1 reply; 7+ messages in thread
From: Adam Beneschan @ 2010-10-22 23:20 UTC (permalink / raw)
On Oct 22, 12:58 pm, Shark8 <onewingedsh...@gmail.com> wrote:
> On Oct 22, 10:22 am, Adam Beneschan <a...@irvine.com> wrote:
>
>
>
>
>
> > On Oct 21, 8:35 pm, Shark8 <onewingedsh...@gmail.com> wrote:
>
> > > 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.
>
> > Not sure what you're trying to do here, or why this is causing a
> > problem. The RM says that the default 'External_Tag is implementation-
> > defined, so you shouldn't depend on it being a certain value, or else
> > you should write your own "for Tagged_Base'External_Tag use ..."
> > clause. My apologies if you already knew this and had some other
> > reason for being surprised.
>
> > -- Adam
>
> > [snip]
>
> > > -- .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.
>
> Ah, the only reason there's an 'External_Tag reference is for output
> onscreen display {lazy shortcutting of
> Ada.Tags.External_Tag(Item'Tag), which should give the same thing};
> the real oddity is the behavior of Is_Descendant_At_Same_Level which
> doesn't readily appear to use the external formatting of the tag.
Is_Descendant_At_Same_Level does appear to be wrong in the DOTNET-GNAT
version. However, as an implementor, I would be very surprised if
Is_Descendant_At_Same_Level tries to use external tags to compute the
result. I guess that's why I was confused by your original statement,
that the difference in external tag behavior "shows why the behavior"
of Is_Descendant_At_Same_level is broken. It should be unrelated.
-- Adam
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Odd/Broken behavior DOTNET-GNAT vs GNAT regarding tagged types.
2010-10-22 23:20 ` Adam Beneschan
@ 2010-10-23 1:57 ` Shark8
2010-10-25 15:34 ` Adam Beneschan
0 siblings, 1 reply; 7+ messages in thread
From: Shark8 @ 2010-10-23 1:57 UTC (permalink / raw)
On Oct 22, 5:20 pm, Adam Beneschan <a...@irvine.com> wrote:
>
> Is_Descendant_At_Same_Level does appear to be wrong in the DOTNET-GNAT
> version. However, as an implementor, I would be very surprised if
> Is_Descendant_At_Same_Level tries to use external tags to compute the
> result. I guess that's why I was confused by your original statement,
> that the difference in external tag behavior "shows why the behavior"
> of Is_Descendant_At_Same_level is broken. It should be unrelated.
>
> -- Adam
Sadly, "should" and "are" are often significantly different. :(
Anyway, I did some poking around and, on opening the Ada.Tags.ADB
file, here's what I found:
package body Ada.Tags is
type String_Access is access all String;
-------------------
-- CW_Membership --
-------------------
function CW_Membership (Obj_Tag : Tag; Typ_Tag : Tag) return
Boolean is
begin
-- ??? This needs to be implemented
raise Program_Error;
return False;
end CW_Membership;
-------------------
-- Expanded_Name --
-------------------
function Expanded_Name (T : Tag) return String is
function Ada_Name (T : Tag) return String_Access;
pragma Import (CIL, Ada_Name,
"mgnat.adalib.GNAT_libc.ada_name");
begin
return Ada_Name (T).all;
end Expanded_Name;
------------------
-- External_Tag --
------------------
function External_Tag (T : Tag) return String is
function Ext_Tag (T : Tag) return String_Access;
pragma Import (CIL, Ext_Tag,
"mgnat.adalib.GNAT_libc.external_tag");
begin
return Ext_Tag (T).all;
end External_Tag;
------------------
-- Internal_Tag --
------------------
function Internal_Tag (External : String) return Tag is
function Int_Tag (External : String) return Tag;
pragma Import (CIL, Int_Tag,
"mgnat.adalib.GNAT_libc.internal_tag");
begin
return Int_Tag (External);
exception
when others => raise Tag_Error;
end Internal_Tag;
--------------------
-- Descendant_Tag --
--------------------
function Descendant_Tag (External : String; Ancestor : Tag) return
Tag is
pragma Unreferenced (Ancestor);
begin
-- ??? This needs to be implemented
return Internal_Tag (External);
end Descendant_Tag;
---------------------------------
-- Is_Descendant_At_Same_Level --
---------------------------------
function Is_Descendant_At_Same_Level
(Descendant : Tag;
Ancestor : Tag) return Boolean
is
pragma Unreferenced (Descendant, Ancestor);
begin
-- ??? This needs to be implemented
return False;
end Is_Descendant_At_Same_Level;
----------------
-- Parent_Tag --
----------------
function Parent_Tag (T : Tag) return Tag is
begin
-- ??? This needs to be implemented
return T;
end Parent_Tag;
end Ada.Tags;
I think it is safe to say the culprit is this: "-- ??? This needs to
be implemented"
Yeah, "not-implemented" is the same as "doesn't work" in many cases.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Odd/Broken behavior DOTNET-GNAT vs GNAT regarding tagged types.
2010-10-23 1:57 ` Shark8
@ 2010-10-25 15:34 ` Adam Beneschan
0 siblings, 0 replies; 7+ messages in thread
From: Adam Beneschan @ 2010-10-25 15:34 UTC (permalink / raw)
On Oct 22, 6:57 pm, Shark8 <onewingedsh...@gmail.com> wrote:
> function Is_Descendant_At_Same_Level
> (Descendant : Tag;
> Ancestor : Tag) return Boolean
> is
> pragma Unreferenced (Descendant, Ancestor);
> begin
> -- ??? This needs to be implemented
> return False;
> end Is_Descendant_At_Same_Level;
Well, that could potentially explain why Is_Descendant_At_Same_Level
is returning an incorrect result, although it probably needs more
investigation to find out for certain, possibly by putting some
Put_Lines in the routine to trace its complicated logical
path. :) :) :)
-- Adam
^ 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