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: "J-P. Rosen" Newsgroups: comp.lang.ada Subject: Re: Can anyone help with GNAT.Perfect_Hash_Generators ? (Possible memory corruption) Date: Fri, 9 Sep 2016 10:25:27 +0200 Organization: A noiseless patient Spider 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: 8bit Injection-Date: Fri, 9 Sep 2016 08:25:31 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="45bffd6a911624777cad79aac3181090"; logging-data="22985"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/gJi6rcfjA+ouaDl3GXAYm" User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 In-Reply-To: Cancel-Lock: sha1:PcaoArqPLAO1IA0QzLsmUEhpDrY= Xref: news.eternal-september.org comp.lang.ada:31737 Date: 2016-09-09T10:25:27+02:00 List-Id: Le 09/09/2016 à 08:04, Natasha Kerensikova a écrit : > 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; > Or even (avoids one copy): function New_Word (S : String) return Word_Type is subtype Slide is String (1 .. S'Length); begin return new String'(Slide(S)); end New_Word; -- J-P. Rosen Adalog 2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX Tel: +33 1 45 29 21 52, Fax: +33 1 45 29 25 00 http://www.adalog.fr