From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.224.125.72 with SMTP id x8mr4129525qar.5.1380205416924; Thu, 26 Sep 2013 07:23:36 -0700 (PDT) X-Received: by 10.49.81.130 with SMTP id a2mr56600qey.15.1380205416904; Thu, 26 Sep 2013 07:23:36 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.glorb.com!d5no1936201qap.0!news-out.google.com!9ni338qaf.0!nntp.google.com!d5no2026209qap.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Thu, 26 Sep 2013 07:23:36 -0700 (PDT) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=129.59.203.113; posting-account=7Oy7OQoAAABhVYFOo553Cn1-AaU-bSfl NNTP-Posting-Host: 129.59.203.113 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <62fd156b-0be2-4465-aeba-287ec9ce22e0@googlegroups.com> Subject: Gnat's Handling of Record with Address Clause From: Eryndlia Mavourneen Injection-Date: Thu, 26 Sep 2013 14:23:36 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:17296 Date: 2013-09-26T07:23:36-07:00 List-Id: The following heavily edited code fragment is disallowed by Gnat: package body Callback_Pkg is Max_Message_Size : constant Natural :=3D 16 * 512; subtype My_Message_L_T is Natural range 1 .. Natural (Max_Message_Siz= e); type My_Buffer_T (My_Message_L : My_Message_L_T) is record My_Message_S : String (1 .. My_Message_L); end record; Local_Buffer_Addr : An_Addr_Type; procedure Callback_Proc (Message : An_Addr_Type; Message_Size : A_Size_Type) is begin Local_Buffer_Addr :=3D Message; Declare_Buffer: declare Local_Buffer : My_Buffer_T with Address =3D> Local_Buffer_Addr; begin Put_Line (...); end Declare_Buffer; end Callback_Proc; end Callback_Pkg; NOTE that type My_Buffer_T, subtype My_Message_L_T, and constant Max_Messag= e_Size are all defined in an external package at top level. I have placed = them here for easy reference. Gnat tells me: 1) (for Local_Buffer) unconstrained subtype not allowed (need initialization) provide initial value or explicit discriminant values or give default discriminant values for type "My_Buffer_T" 2) (also for Local_Buffer) invalid address clause for initialized object "Local_Buffer" reference to variable "Local_Buffer_Addr" not allowed (RM 13.1(22)) I can understand (1), and I can initialize the record's discriminant, doing= away with this message; however, I do not understand that (2) says the rec= ord is initialized, unless it is some kind of default initialization. RM 13.1(22) says: "An implementation need not support the specification for= a representation aspect that contains nonstatic expressions, unless each n= onstatic expression is a name that statically denotes a constant declared b= efore the entity." The overall effect of all this appears to be that Gnat is allowed to disall= ow a dynamically-determined address for an object. If this is what is happ= ening here (not a bug in Gnat), then it would seem that any kind of OS work= , looping through a kernel linked list, for instance, would not be possible= . A further NOTE: (1) says truthfully that the immediate definition of Local= _Buffer is not initialized; however, that assumption ignores the address cl= ause. With the address clause, Local_Buffer *is* initialized at the specif= ied address. Perhaps Gnat's error should be changed to a warning in this c= ase. Any help here on these issues? -- Eryndlia (KK1T)