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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,75d2eb9e2e52a8c5 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!t19g2000yql.googlegroups.com!not-for-mail From: Anh Vo Newsgroups: comp.lang.ada Subject: Re: Problem where a function is invoked once but called twice (when invocation is within an allocator). Date: Mon, 9 May 2011 17:14:07 -0700 (PDT) Organization: http://groups.google.com Message-ID: <85890ff0-343f-4d79-aba0-c3d214b4a28e@t19g2000yql.googlegroups.com> References: <87r58dxeia.fsf@mid.deneb.enyo.de> <17caa8eb-8113-4199-83b7-9b199887a758@k15g2000pri.googlegroups.com> <68228b55-070c-4678-b584-8278988e73fc@k3g2000prl.googlegroups.com> NNTP-Posting-Host: 149.32.224.33 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1304986447 16501 127.0.0.1 (10 May 2011 00:14:07 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 10 May 2011 00:14:07 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: t19g2000yql.googlegroups.com; posting-host=149.32.224.33; posting-account=Qh2kiQoAAADpCLlhT_KTYoGO8dU3n4I6 User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows NT 5.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1,gzip(gfe) Xref: g2news2.google.com comp.lang.ada:20176 Date: 2011-05-09T17:14:07-07:00 List-Id: On May 9, 4:00=A0pm, Dan wrote: > Here's a simpler test case. =A0Taking out the Pragma Pack makes it work. > > package Media is > > =A0 =A0type Color is > =A0 =A0 =A0 record > =A0 =A0 =A0 =A0 =A0val : integer; > =A0 =A0 =A0 end record; > > =A0 =A0type Image is array (integer range <>) of Color; > =A0 =A0pragma pack (Image); =A0 =A0 =A0 =A0 -- matters! > > =A0 =A0function next_Frame return Image; > > end Media; > > with Ada.Text_IO; use Ada.Text_IO; > package body Media is > =A0 =A0counter: integer :=3D 0; > > =A0 =A0function next_Frame return Image is > =A0 =A0begin > =A0 =A0 =A0 put_line("in next_frame"); > =A0 =A0 =A0 counter :=3D counter + 1; > =A0 =A0 =A0 return (1..10 =3D> (val =3D> counter)); > =A0 =A0end next_Frame; > > end Media; > > with Media; > with text_io; > procedure Test1 is > > =A0 =A0Case_1 : =A0 =A0 =A0 =A0Media.Image :=3D =A0 =A0 Media.Image' (Med= ia.next_Frame); > =A0 =A0Case_2 : access Media.Image :=3D new Media.Image' (Media.next_Fram= e); > begin > =A0 =A0text_io.put_line(case_1(5).val'img); > =A0 =A0text_io.put_line(case_2(5).val'img); > end; Thank you for making the simplest test case. I got double calls, too. It is absolutely a compiler bug. Anh Vo