comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: GNAT or Language Problems?
Date: Sat, 17 Jun 2023 02:28:58 -0500	[thread overview]
Message-ID: <u6jnbi$15r2k$1@dont-email.me> (raw)
In-Reply-To: u558m9$1ub3o$1@dont-email.me

Regarding your second problem, refer to AI22-0041-1.

Essentially, there are problems if predicates are involved. We changed the 
rule to require static compatibility (as a Binding Interpretation). I don't 
have the energy to look up what "static compatibility" requires in this case 
(enjoy figuring out 4.9.1). In some cases, it requires static matching, in 
others, it has weaker requirements.

It's possible that GNAT did something too strong when fixing this problem, 
as well.

I don't have the time or energy tonight to look into your other problem. 
(I'm waiting for a backup to finish, or I would have already gone home --  
since I only got back from Lisbon last night, I'm not equipped for my usual 
late night work...)

              Randy.

"Jeffrey R.Carter" <spam.jrcarter.not@spam.acm.org.not> wrote in message 
news:u558m9$1ub3o$1@dont-email.me...
> Here are a couple of things that recent versions of GNAT reject, and I 
> suspect that these are GNAT errors, but would appreciate input from 
> language lawyers to be sure. If they're not GNAT errors, then they seem 
> like things that make Ada less easy to use than I'd like.
>
> The first is gcc bug 108157 
> (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108157). GNAT.Sockets has
>
> package GNAT.Sockets is
>    ...
>    type Selector_Type is limited private;
>    ...
>    procedure Connect_Socket
>      (Socket   : Socket_Type;
>       Server   : Sock_Addr_Type;
>       Timeout  : Selector_Duration;
>       Selector : access Selector_Type := null;
>       Status   : out Selector_Status);
>    --  Connect Socket to the given Server address using Connect_Socket, 
> waiting
>    --  no longer than the given timeout duration. Status is set to 
> indicate
>    --  whether the operation completed successfully, timed out, or was 
> aborted.
>    --  If Selector is not null, the designated selector is used to wait 
> for the
>    --  socket to become available, else a private selector object is 
> created
>    --  by this procedure and destroyed before it returns. If Timeout is 
> 0.0,
>    --  no attempt is made to detect whether the connection has succeeded; 
> it
>    --  is up to the user to determine this using Check_Selector later on.
>    ...
> private
>    ...
>    type Selector_Type (Is_Null : Boolean := False) is limited record
>       case Is_Null is
>          when True =>
>             null;
>
>          when False =>
>             R_Sig_Socket : Socket_Type := No_Socket;
>             W_Sig_Socket : Socket_Type := No_Socket;
>             --  Signalling sockets used to abort a select operation
>       end case;
>    end record;
>    ...
> end GNAT.Sockets;
>
> Kazakov's GNAT.Sockets.Server had (since modified to work with recent 
> versions of GNAT)
>
> package GNAT.Sockets.Server is
>    ...
>    type Connections_Server is tagged limited private;
>    ...
> private
>    ...
>    procedure Do_Connect
>      (Listener : in out Connections_Server'Class;
>       Client   : in out Connection_Ptr);
>    ...
>    type Connections_Server is tagged limited record
>       --  limited because Selector_Type is limited
>       Selector : aliased Selector_Type;
>    end record;
>    ...
> end GNAT.Sockets.Server;
>
> and
>
> package body GNAT.Sockets.Server is
>    ...
>    procedure Do_Connect
>      (Listener : in out Connections_Server'Class;
>       Client   : in out Connection_Ptr)
>    is
>       Status : Selector_Status;
>    begin
>       Connect_Socket
>         (Socket   => Client.Socket,
>          Server   => Client.Client_Address,
>          Timeout  => 0.0,
>          Selector => Listener.Selector'Unchecked_Access,
>          Status   => Status);
>    end Do_Connect;
>    ...
> end GNAT.Sockets.Server;
>
> Beginning with GNAT 12, the parameter association
>
>    Selector => Listener.Selector'Unchecked_Access,
>
> gives the error
>
>    object subtype must statically match designated subtype
>
> The FSF GNAT maintainers have decided not to change this, citing
>
>         --  Ada 2005 (AI-363): Require static matching when designated
>         --  type has discriminants and a constrained partial view, since
>         --  in general objects of such types are mutable, so we can't
>         --  allow the access value to designate a constrained object
>         --  (because access values must be assumed to designate mutable
>         --  objects when designated type does not impose a constraint).
>
> I think that those who use anonymous access types get what they deserve, 
> but had the parameter been mode "in out", there would be no problem. I 
> think that access parameters should work the same as "in out" parameters 
> as much as possible.
>
> So, GNAT or Ada problem, or is this a reasonable restriction?
>
> The other instance is in PragmARC.B_Strings 
> (https://github.com/jrcarter/PragmARC):
>
> package PragmARC.B_Strings is
>    type B_String (Max_Length : Positive := 1024) is tagged limited 
> private;
>    -- Default initial value is Null_B_String
>
>    Null_B_String : constant B_String; -- A string of zero characters
>    ...
> private -- PragmARC.B_Strings
>    type B_String (Max_Length : Positive := 1024) is tagged limited record
>       Len   : Natural := 0;
>       Value : String (1 .. Max_Length) := (1 .. Max_Length => ' ');
>    end record;
>
>    Null_B_String : constant B_String := (Max_Length => 1, others => <>);
> end PragmARC.B_Strings;
>
> Beginning with GNAT 13, an error on the full declaration of the constant 
> says that its subtype does not statically match that of the deferred 
> declaration.
> A workaround is to explicitly declare the discriminant value on both 
> declarations. Probably making the full declaration be (others => <>) would 
> also work.
>
> I don't see this in ARM 7.4; only constants of an anonymous access type 
> have to statically match. So this is probably a compiler error, but I 
> thought I would see what the experts think.
>
> -- 
> Jeff Carter
> "Ada is a management tool. It selects for software
> engineers and encourages the hackers to quit."
> Robert C. Leif
> 204 


  reply	other threads:[~2023-06-17  7:28 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-30 16:36 GNAT or Language Problems? Jeffrey R.Carter
2023-06-17  7:28 ` Randy Brukardt [this message]
2023-06-17  9:21   ` Jeffrey R.Carter
2023-06-17 17:50     ` Bill Findlay
2023-06-17 20:49       ` Jeffrey R.Carter
2023-06-22  9:51     ` Randy Brukardt
2023-06-22 12:56       ` Jeffrey R.Carter
2023-06-23  9:55         ` Randy Brukardt
2023-06-24 12:23           ` Jeffrey R.Carter
2023-06-26 21:42             ` Randy Brukardt
2023-06-27 10:16               ` Jeffrey R.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