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.rRj2NI6co7bdwVi/aIVhOQ.user.gioia.aioe.org!not-for-mail From: russ lyttle Newsgroups: comp.lang.ada Subject: Re: Gnat Problem - Freezing too soon Date: Thu, 28 Feb 2019 17:11:08 -0500 Organization: Aioe.org NNTP Server Message-ID: References: NNTP-Posting-Host: rRj2NI6co7bdwVi/aIVhOQ.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 X-Notice: Filtered by postfilter v. 0.9.2 Content-Language: en-US Xref: reader01.eternal-september.org comp.lang.ada:55725 Date: 2019-02-28T17:11:08-05:00 List-Id: On 2/28/19 4:22 PM, Simon Wright wrote: > russ lyttle writes: > >> Example from the bookAnalysable Real-Time Systems : >> >> 1 package Environment_Monitor.Ch4_Status is --Protected >> 2 protected type Methane_Agent (Ceiling : Priority) >> 3 with Priority => Ceiling >> 4 is new CH4_Safety >> 5 with >> 6 overriding function Check_Safe return Methane_Status; >> 7 overriding procedure Set_Safety (M : Methane_Status); >> 8 private >> 9 Current_Status : Methane_Status := Motor_Unsafe; >> 10 end Methane_Agent; >> 11 end Environment_Monitor.Ch4_Status; >> >> Gnat complains that Methane_Agent is frozen at line 2, and line 3 is >> trying to change an attribute after being frozen. > The resolution may well be to upgrade your compiler. GNAT GPL 2017 and > FSF GCC 8 are both happy with this compilable demonstrator: > > > with System; > with Ada.Text_IO; > procedure Russ is > > package P is > > type Parent is synchronized interface; > function Is_Safe (P : Parent) return Boolean is abstract; > procedure Set_Safety (P : in out Parent; To : Boolean) is abstract; > > protected type Child (Ceiling : System.Priority) > with Priority => Ceiling > is new Parent with > overriding > function Is_Safe return Boolean; > overriding > procedure Set_Safety (To : Boolean); > private > Safety : Boolean := False; > end Child; > > end P; > > package body P is > > protected body Child is > function Is_Safe return Boolean is (Safety); > procedure Set_Safety (To : Boolean) is > begin > Safety := To; > end Set_Safety; > end Child; > > end P; > > A_Child : P.Child (Ceiling => System.Priority'Last); > > begin > Ada.Text_IO.Put_Line (A_Child.Is_Safe'Img); > A_Child.Set_Safety (True); > Ada.Text_IO.Put_Line (A_Child.Is_Safe'Img); > end Russ; > > Running Ubuntu 18.10, > gcc --version is 8.2.0 > gnat --version is 7.3.0 Ubuntu has version 7.3.0 as default and 8.2.0 as available. I tried upgrading to gnat-8 (8.2.0) and package and Environment_Monitor.Ch4_Status now compiles fine. However, I now get this: +=======================GNAT BUG DETECTED==============================+ | 8.2.0 (x86_64-linux-gnu) GCC error: | | in gnat_to_gnu_entity, at ada/gcc-interface/decl.c:425 | | Error detected at sporadics.ads:44:23 | | Please submit a bug report; see https://gcc.gnu.org/bugs/ . | | Use a subject line meaningful to you and us to track the bug. | | Include the entire contents of this bug box in the report. | | Include the exact command that you entered. | | Also include sources listed below. | +==========================================================================+ Please include these source files with error report Note that list may not be accurate in some cases, so please double check that the problem can still be reproduced with the set of files listed. Consider also -gnatd.n switch (see debug.adb). /media/russ/Projects/Ada/Analysable_RTS/Chap20/Common/sporadics.adb /media/russ/Projects/Ada/Analysable_RTS/Chap20/Common/sporadics.ads ------------ From sporadics.ads: 42 task type Sporadic (S : Any_Sporadic_State; 43 A : Any_Sporadic_Thread_Interface) 44 with Priority => S.Pri is 45 end Sporadic; Both of the above files compiled and and ran under gnat-7 The mine_control_system.gpr file is pretty simple: project Mine_Control_System is for Source_Dirs use ("Common", "Data_Logger", "Environment_Monitor", "Main", "Operator_Console", "Pump_Controller", "Mine_Control_System" ); for Ignore_Source_Sub_Dirs use (".svn", "@*"); for Object_Dir use "Obj"; for Exec_Dir use "."; for Main use ("main.adb"); end Mine_Control_System; ---------- Would I be submitting a bug report against an already patched version of gnat?