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 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED.rTTHrRV7loqfBpYU9tzJSw.user.gioia.aioe.org!not-for-mail From: russ lyttle Newsgroups: comp.lang.ada Subject: Re: Gnat Problem - Freezing too soon Date: Sat, 2 Mar 2019 15:19:41 -0500 Organization: Aioe.org NNTP Server Message-ID: References: <2c369d78-70ea-4593-af3d-e014b0c1fc00@googlegroups.com> <4081906e-91de-43fa-a816-067f707c6d7d@googlegroups.com> <161c749f-b9db-465f-8ffe-7900d3a4bff5@googlegroups.com> NNTP-Posting-Host: rTTHrRV7loqfBpYU9tzJSw.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 Content-Language: en-US X-Notice: Filtered by postfilter v. 0.9.2 Xref: reader01.eternal-september.org comp.lang.ada:55767 Date: 2019-03-02T15:19:41-05:00 List-Id: On 3/2/19 12:50 AM, Anh Vo wrote: > On Friday, March 1, 2019 at 7:56:40 PM UTC-8, russ lyttle wrote: >> On 3/1/19 8:08 PM, Anh Vo wrote: >>> On Friday, March 1, 2019 at 1:50:12 PM UTC-8, russ lyttle wrote: >>>> On 3/1/19 11:54 AM, Anh Vo wrote: >>>>> On Friday, March 1, 2019 at 6:21:26 AM UTC-8, russ lyttle wrote: >>>>>> On 2/28/19 7:49 PM, Anh Vo wrote: >>>>>>> On Thursday, February 28, 2019 at 2:11:11 PM UTC-8, russ lyttle wrote: >>>>>>>> On 2/28/19 4:22 PM, Simon Wright wrote: >>>>>>>>> russ lyttle writes: >>>>>>>>> >>>>>>>>>> Example from the bookAnalysable Real-Time Systems : >>>>>>>>>> >>>>>>> --------- >>>>>>>> >>>>>>>> Would I be submitting a bug report against an already patched version of >>>>>>>> gnat? >>>>>>> >>>>>>> Again, please post sporadics.ads in its entirety. So, we can duplicate your finding or not. >>>>>>> >>>>>>> >>>>>> Thanks for responding. We found it definitely a bug in gnat and are >>>>>> submitting a bug report. >>>>> >>>>> It is fine to send in a report if you are confident that it is a bug in latest GNAT. Otherwise, we would like to see the content of sporadics.ads. So, we can either confirm or not your finding. >>>>> >>>>> >>>> Here they are. These are from Analysable Real-Time Systems Progrmmed in >>>> Ada, Chap.20, Pg. 472-473. Line 29 gives different error from line 44. >>>> >>>> Full code for sporadics.ads: >>>> >>>> with System; use System; >>>> with Ada.Real_Time; use Ada.Real_Time; >>>> package Sporadics is >>>> >>>> type Sporadic_Invoke_Interface is Synchronized Interface; >>>> procedure Start (S: in out Sporadic_Invoke_Interface) >>>> is abstract; >>>> type Any_Sporadic_Invoke_Interface is access all >>>> Sporadic_Invoke_Interface'Class; >>>> >>>> type Sporadic_Thread_Interface is Synchronized Interface; >>>> procedure Wait_Start (S: in out Sporadic_Thread_Interface) >>>> is abstract; >>>> type Any_Sporadic_Thread_Interface is access all >>>> Sporadic_Thread_Interface'Class; >>>> >>>> type Sporadic_State is abstract tagged >>>> record >>>> Pri : Priority; >>>> Ceiling_Priority : Priority; >>>> MIT_In_Mili : Time_Span; >>>> end record; >>>> procedure Initialize_Code (S: in out Sporadic_State) >>>> is abstract; >>>> procedure Sporadic_Code (S: in out Sporadic_State) >>>> is abstract; >>>> type Any_Sporadic_State is access all Sporadic_State'Class; >>>> >>>> protected type Sporadic_Agent (S: Any_Sporadic_State) >>>> --with Priority => S.Ceiling_Prioriy >>>> is >>>> new Sporadic_Invoke_Interface and >>>> Sporadic_Thread_Interface >>>> with >>>> -- for the Start operation >>>> overriding procedure Start; >>>> overriding entry Wait_Start; >>>> private >>>> Start_Open : Boolean := False; >>>> end Sporadic_Agent; >>>> >>>> task type Sporadic (S : Any_Sporadic_State; >>>> A : Any_Sporadic_Thread_Interface) >>>> with Priority => S.pri >>>> is >>>> >>>> end Sporadic; >>>> end Sporadics; >>>> ----------------------------------------------------------------------- >>>> Full code for sporadics.adb: >>>> package body Sporadics is >>>> protected body Sporadic_Agent is >>>> procedure Start is >>>> begin >>>> Start_Open := False; >>>> end Start; >>>> >>>> entry Wait_Start >>>> when Start_Open is >>>> begin >>>> Start_Open := False; >>>> end Wait_Start; >>>> end Sporadic_Agent; >>>> >>>> task body Sporadic is >>>> begin >>>> S.Initialize_Code; >>>> loop >>>> A.Wait_Start; >>>> S.Sporadic_Code; >>>> end loop; >>>> end Sporadic; >>>> end Sporadics; >>> >>> This problem also occurred with GNAT Community 2018 on Windows. >>> >>> While waiting for fixes in GNAT Community 2019, the work around is changing the definition of type Any_Sporadic_State as shown below. >>> >>> type Any_Sporadic_State is not null access all Sporadic_State'Class; >>> >> Well, that worked. I may even come to understand why. Is this gnat only? > > It is standard Ada. It means that the access variable must be not null. > I understand that. I meant why it solved this particular problem. As far as I can tell, the authors never used the "not null" in any of their books. Would other compilers accept the code as written, or should the code be considered erroneous? As Simon pointed out replacing "with Priority => S.pri" with "pragma Priority(S.pri)" also works. They never used that form either. Why would the authors prefer one form over the others?