comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: To collection (GNAT bug)
Date: Mon, 2 Oct 2006 15:43:59 +0200
Date: 2006-10-02T15:43:56+02:00	[thread overview]
Message-ID: <u0sk26qjz46b$.1v1mgzx5feup8$.dlg@40tude.net> (raw)
In-Reply-To: 1c8Ug.2616$O5.1996@llslave.llan.ll.mit.edu

On Mon, 02 Oct 2006 09:06:42 -0400, Frank J. Lhota wrote:

> Dmitry A. Kazakov wrote:
>> On Sun, 01 Oct 2006 19:23:26 GMT, Jeffrey R. Carter wrote:
>> However, I don't think that it was really the intended behavior in this
>> case. [ If access String is a fat pointer, then Unchecked_Conversion should
>> not be allowed at all. Otherwise it must honor the String's dope. ]
> 
> I would agree that an unchecked conversion between an address and a fat 
> pointer (or any two types of different sizes, for that matter) should at 
> least trigger a warning.

Well, actually, it gives a warning, that sizes are different. I think that
a warning is not enough. But there is a nasty issue with generics. Let
Unchecked_Conversion were instantiated in a generic body, then the compiler
should either forbid or support conversions of all access types - it never
knows if the actual access type were fat.

A cleaner way were, IMO, to pass the conversion as a formal parameter and
allow ad-hoc instantiations as subprogram defaults. Something like:

generic
   type T is ...;
   type Ptr is access T; -- It could be fat
   with function To_Ptr (A : Address) return Ptr is
      new Ada.Unchecked_Conversion (T, Ptr);
package Separately_Compilable_Generic_Body is

Then the compiler could safely compile the body and complain upon an
instantiation.

But it still does not help when the access type is declared within the
generic body. Then the compiler should forget about fat pointers.

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



  reply	other threads:[~2006-10-02 13:43 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
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 [this message]
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