comp.lang.ada
 help / color / mirror / Atom feed
From: Dan <dan@irvine.com>
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)
Date: 2011-05-09T16:00:14-07:00	[thread overview]
Message-ID: <68228b55-070c-4678-b584-8278988e73fc@k3g2000prl.googlegroups.com> (raw)
In-Reply-To: e35c30a9-580a-4607-8bd2-ae21a92dd2e9@h9g2000yqk.googlegroups.com

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;




  reply	other threads:[~2011-05-09 23:00 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-05  3:52 Problem where a function is invoked once but called twice (when invocation is within an allocator) Rod Kay
2011-05-05  5:43 ` J-P. Rosen
2011-05-05  6:12   ` Rod Kay
2011-05-05  8:22   ` Yannick Duchêne (Hibou57)
2011-05-05 10:59     ` Rod Kay
2011-05-05 17:07       ` Florian Weimer
2011-05-06  0:49         ` Rod Kay
2011-05-06 23:41           ` Anh Vo
2011-05-07  1:38             ` Rod Kay
2011-05-07  9:06               ` Georg Bauhaus
2011-05-07  9:45                 ` Rod Kay
2011-05-09 16:01               ` Anh Vo
2011-05-09 23:00                 ` Dan [this message]
2011-05-10  0:14                   ` Anh Vo
2011-05-10  0:24                     ` Rod Kay
2011-05-10  0:55                       ` Anh Vo
2011-05-11 17:23                         ` Dan
2011-05-12 22:35                         ` Rod Kay
2011-05-13 17:40                           ` Ludovic Brenta
2011-05-10  0:21                   ` Rod Kay
  -- strict thread matches above, loose matches on Subject: below --
2011-05-14  0:27 Rod Kay
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox