comp.lang.ada
 help / color / mirror / Atom feed
From: "Grein, Christoph" <christoph.grein@eurocopter.com>
To: comp.lang.ada@ada.eu.org
Subject: Re: Repost: Nobody interested to judge which compiler is right?!
Date: Thu, 30 Jan 2003 07:53:06 +0100 (MET)
Date: 2003-01-30T07:53:06+01:00	[thread overview]
Message-ID: <mailman.15.1043910058.30820.comp.lang.ada@ada.eu.org> (raw)

Well I'm no language lawyer, but in my opinion, Gnat is wrong and Aonix is 
right.

> with Ada.Strings.Fixed; use Ada.Strings.Fixed;
> with Ada.Text_IO; use Ada.Text_IO;
> 
> procedure Tiny is
> -- Is this code valid ?!
> 
> 	type String_Access is access all String;
> 
> 	subtype Len_Positive is Positive range 1 .. 20;
> 	subtype Len_String is String ( Len_Positive );
> 	subtype Len_String_Access is String_Access( Len_Positive );
> 
> 	LS : aliased Len_String := Len_String'Length * "*";
> 
> 
> 	-- \/ This compiles with GNAT, but not with Aonix
> 	LSA : Len_String_Access := LS'access;
> 
> 
> begin
> 
> 	-- \/ This compiles with GNAT, but not with Aonix
> 	Put_Line( LSA.all );
> 
> end Tiny;

LS nominal and actual subtypes are the same: Len_String

The designated subtype of String_Access and Len_String_Access both are String, 
i.e. an unconstrainted subtype. This is from a note of Tucker Taft on Team Ada 
March 1999. I have no longer the exact English wording, I retranslate from 
German:

"The designated subtype is determined by the declaration of an access type, it 
is the same for all subtypes of that access type, even when the access subtypes 
pose some constraints on the designated subtype."

You could try

  LS : aliased String := Len_String'Length * "*";

Now the nominal subtype of LS is String, the actual subtype is Len_String, i.e. 
LS is constrained by its initial value. Now the subtypes match and

  LSA : Len_String_Access := LS'access;

should be OK. (Warning: I haven't compiled this.)



             reply	other threads:[~2003-01-30  6:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-01-30  6:53 Grein, Christoph [this message]
2003-01-30 18:52 ` Repost: Nobody interested to judge which compiler is right?! Wojtek Narczynski
2003-01-30 20:19   ` Robert A Duff
  -- strict thread matches above, loose matches on Subject: below --
2003-01-31  6:25 Grein, Christoph
2003-01-29 23:00 Wojtek Narczynski
2003-01-30  0:13 ` tmoran
replies disabled

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