From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-65-14.ec2.internal X-Spam-Level: * X-Spam-Status: No, score=1.1 required=3.0 tests=AC_FROM_MANY_DOTS,BAYES_00, T_FILL_THIS_FORM_SHORT,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: "Jeffrey R.Carter" Newsgroups: comp.lang.ada Subject: GNAT or Language Problems? Date: Tue, 30 May 2023 18:36:25 +0200 Organization: A noiseless patient Spider Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Tue, 30 May 2023 16:36:25 -0000 (UTC) Injection-Info: dont-email.me; posting-host="882d8a395c9cb0cfcf17b8727bb7e01b"; logging-data="2043000"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+QbgM+GY+GFJemfyLBnjZhmH56TflEGVc=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Cancel-Lock: sha1:8EdUyXfRp4ChhiNYqV7brfCzFwM= Content-Language: en-US Xref: news.eternal-september.org comp.lang.ada:65275 List-Id: 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