comp.lang.ada
 help / color / mirror / Atom feed
From: Matthew Woodcraft <mattheww@chiark.greenend.org.uk>
Subject: Re: Using renaming declarations to make private subprograms visible
Date: 26 Aug 2001 11:59:39 +0100
Date: 2001-08-26T11:59:39+01:00	[thread overview]
Message-ID: <87heuv6q90.fsf@chiark.greenend.org.uk> (raw)
In-Reply-To: 3B87EDC9.A6D626E8@acm.org

Jeffrey Carter <jrcarter@acm.org> writes:

> This compiles with GNAT 3.13p:
> 
>    function Convert_To_String (Source : Token_Type) return String
>       renames To_String;
> 
>    function To_String (Source : Token_Type) return String
>       renames Convert_To_String;

Yes, it compiles. I tried this before, but I didn't actually run it: it
seems to me that it's just a circular renaming that the compiler doesn't
catch (though I'm surprised the compiler isn't required to catch it).

At any rate, I've tried now, and the code below doesn't run for me with
GNAT 3.13p (segmentation fault, with a stack backtrace containing many
thousands of identical entries).

As an aside, if I want to use -fstack-check, do I have to recompile the
entire runtime?

-M-

===

with Ada.Strings.Unbounded;
package Renaming is

   type Token_Type is private;

   function To_Token (Source : String) return Token_Type;

   function To_String (Source : Token_Type) return String;

private

   type Token_Type is new Ada.Strings.Unbounded.Unbounded_String;

   function To_Token (Source : String) return Token_Type
     renames To_Unbounded_String;

   function Convert_To_String (Source : Token_Type) return String
      renames To_String;

   function To_String (Source : Token_Type) return String
      renames Convert_To_String;

end Renaming;



with Renaming; use Renaming;
with Ada.Text_IO; use Ada.Text_IO;
procedure Try_Renaming is

   S  : constant String := "Hello World";
   T  : Token_Type;

begin
   T := To_Token (S);

   declare
      New_S : constant String := To_String (T);
   begin
      Put (S);
      Put (New_S);
   end;

end Try_Renaming;





  reply	other threads:[~2001-08-26 10:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-08-25 13:13 Using renaming declarations to make private subprograms visible Matthew Woodcraft
2001-08-25 18:27 ` Jeffrey Carter
2001-08-26 10:59   ` Matthew Woodcraft [this message]
2001-08-26 12:29     ` Marc A. Criley
2001-08-27  5:31     ` Jeffrey Carter
replies disabled

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