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=ham 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-7-bit Path: g2news1.google.com!postnews.google.com!k3g2000prl.googlegroups.com!not-for-mail From: Dan 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 16:00:14 -0700 (PDT) Organization: http://groups.google.com Message-ID: <68228b55-070c-4678-b584-8278988e73fc@k3g2000prl.googlegroups.com> References: <87r58dxeia.fsf@mid.deneb.enyo.de> <17caa8eb-8113-4199-83b7-9b199887a758@k15g2000pri.googlegroups.com> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1304982015 15223 127.0.0.1 (9 May 2011 23:00:15 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 9 May 2011 23:00:15 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: k3g2000prl.googlegroups.com; posting-host=66.126.103.122; posting-account=mj1SqQkAAAC-ugS7xMajTlZAhqdqcRbD User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; HPDTDF; .NET4.0C),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:19204 Date: 2011-05-09T16:00:14-07:00 List-Id: Here's a simpler test case. Taking out the Pragma Pack makes it work. package Media is type Color is record val : integer; end record; type Image is array (integer range <>) of Color; pragma pack (Image); -- matters! function next_Frame return Image; end Media; with Ada.Text_IO; use Ada.Text_IO; package body Media is counter: integer := 0; function next_Frame return Image is begin put_line("in next_frame"); counter := counter + 1; return (1..10 => (val => counter)); end next_Frame; end Media; with Media; with text_io; procedure Test1 is Case_1 : Media.Image := Media.Image' (Media.next_Frame); Case_2 : access Media.Image := new Media.Image' (Media.next_Frame); begin text_io.put_line(case_1(5).val'img); text_io.put_line(case_2(5).val'img); end;