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!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: "Jeffrey R. Carter" Newsgroups: comp.lang.ada Subject: Re: Can anyone help with GNAT.Perfect_Hash_Generators ? (Possible memory corruption) Date: Thu, 8 Sep 2016 23:15:41 -0700 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: <397dd8cb-2afc-43cd-972d-3b1a5a90cd5d@googlegroups.com> <877fao24da.fsf@mid.deneb.enyo.de> <0b79fce9-b898-4a1c-91fb-ca41e87b4dd5@googlegroups.com> <08e0581a-30f1-4cc5-972c-2d6c539d9df6@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Injection-Date: Fri, 9 Sep 2016 06:15:46 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="6df4b173985f7c5c043cea362c370ff7"; logging-data="1801"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX195Dhg2fELs5cu0yA5i5PFKq0Q3X1sDLcg=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 In-Reply-To: Cancel-Lock: sha1:2YbPVyos1QQ8PWxM9k/Sb5EJaEY= Xref: news.eternal-september.org comp.lang.ada:31736 Date: 2016-09-08T23:15:41-07:00 List-Id: On 09/08/2016 11:04 PM, Natasha Kerensikova wrote: > > On 2016-09-08, Jeffrey R. Carter wrote: >> >> Clearly it needs to have the assumption, that all Strings have a lower bound of >> 1, eliminated. >> > > I thought it would be easier to make the assumption internally true > instead. > > Since the first thing it does with the input is to copy it internally > using the function New_Word, I would propose a fix along the line of > replacing it from > > function New_Word (S : String) return Word_Type is > begin > return new String'(S); > end New_Word; > > to > > function New_Word (S : String) return Word_Type is > Result : Word_Type := new String (1 .. S'Length); > begin > Result.all := S; > return Result; > end New_Word; Perhaps I should have said, "all Strings passed to it have a lower bound of 1". Clearly it can ensure any characteristic it likes about Strings it creates. The current approach assumes S has a lower bound of 1; your proposal does not. So I consider your proposal as doing what I said. Does return new String (1 .. S'Length)'(S); work? -- Jeff Carter "English bed-wetting types." Monty Python & the Holy Grail 15