comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: To collection (GNAT bug)
Date: Sun, 1 Oct 2006 10:00:43 +0200
Date: 2006-10-01T10:00:24+02:00	[thread overview]
Message-ID: <ioiqz1x0cf1a$.o6bzardt4n7d.dlg@40tude.net> (raw)
In-Reply-To: mKETg.218023$1i1.149463@attbi_s72

On Sun, 01 Oct 2006 01:21:22 GMT, Jeffrey R. Carter wrote:

> Dmitry A. Kazakov wrote:
>> The following does not work in GCC 4.1.1 (20060525), as well as in 3.15p
> 
> Why should it? There's no guarantee that unchecked conversion between 
> access values and System.Address will give meaningful results.

See ARM 13.9 (17), which requires reversibility of Unchecked_Conversion.
That is clearly violated in the example given. Though it is legal not to
provide address to access type conversion through Unchecked_Conversion, it
is still illegal to provide it wrong.

> Use System.Address_To_Access_Conversions.

Address_To_Access_Conversions serves a different purpose. It declares a new
access type, moreover it is a general access type.

BTW, when Address_To_Access_Conversions is composed with an access to
access type conversion, the problem persists (it is a bug after all (:-))
Replace To_Ptr and To_Addr with:

   package Clutter is new Address_To_Access_Conversions (String);
   function To_Addr (X : Ptr) return Address is
   begin
      return Clutter.To_Address (X.all'Unchecked_Access);
   end To_Addr;
   function To_Ptr (X : Address) return Ptr is
      function Cast is
         new Ada.Unchecked_Conversion (Clutter.Object_Pointer, Ptr);
   begin
      return Cast (Clutter.To_Pointer (X));
   end To_Ptr;

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



  reply	other threads:[~2006-10-01  8:00 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-30 19:46 To collection (GNAT bug) Dmitry A. Kazakov
2006-10-01  1:21 ` Jeffrey R. Carter
2006-10-01  8:00   ` Dmitry A. Kazakov [this message]
2006-10-01 19:23     ` Jeffrey R. Carter
2006-10-01 22:33       ` Frank J. Lhota
2006-10-02  3:08         ` Jeffrey R. Carter
2006-10-02 13:02           ` Frank J. Lhota
2006-10-02 19:50             ` Jeffrey R. Carter
2006-10-02  8:23       ` Dmitry A. Kazakov
2006-10-02 13:06         ` Frank J. Lhota
2006-10-02 13:43           ` Dmitry A. Kazakov
2006-10-04 17:18             ` Adam Beneschan
2006-10-04 18:51               ` Dmitry A. Kazakov
2006-10-02 19:45         ` Jeffrey R. Carter
2006-10-03  8:36           ` Dmitry A. Kazakov
2006-10-03 19:10             ` Jeffrey R. Carter
2006-10-04  8:01               ` Dmitry A. Kazakov
2006-10-04  9:27                 ` Georg Bauhaus
2006-10-04 12:10                   ` Dmitry A. Kazakov
replies disabled

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