comp.lang.ada
 help / color / mirror / Atom feed
* Does object renaming allow the view to be a copy?
@ 2017-01-22  8:27 G.B.
  2017-01-22 10:37 ` Simon Wright
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: G.B. @ 2017-01-22  8:27 UTC (permalink / raw)


A SO answer (41746244) has given rise to the question of whether
or not a compiler implementer may make a renamed object a copy
of the original. (Layman's assumptions from LRM 3.1(7), 8.5.1),

So, is the following program, modifying compoments of and array,
ever allowed to raise Renaming_Is_Copying?

with System;
procedure Renaming is

     Renaming_Is_Copying : exception;

     type R is record
         A, B : Integer;
     end record;

     type List is array (Natural range <>) of R;
     Stuff : List := (10 .. 20 => R'(A => 2, B => 3));
begin
     for K in Stuff'Range loop
         declare
             --
             --  Does Ada allow a compiler to make X be a copy?
             --
             X : R renames Stuff (K);
             use type System.Address;
         begin
             if X'Address = Stuff (K)'Address then
                 X.A := X.B;
             else
                 raise Renaming_Is_Copying;
             end if;
         end;
     end loop;
end Renaming;

-- 
"HOTDOGS ARE NOT BOOKMARKS"
Springfield Elementary teaching staff

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2017-01-24 21:08 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-22  8:27 Does object renaming allow the view to be a copy? G.B.
2017-01-22 10:37 ` Simon Wright
2017-01-22 16:26 ` AdaMagica
2017-01-22 17:37   ` Simon Wright
2017-01-22 20:24     ` Dmitry A. Kazakov
2017-01-23 10:49       ` AdaMagica
2017-01-23 11:06         ` Dmitry A. Kazakov
2017-01-23 20:40 ` Randy Brukardt
2017-01-24 16:06   ` Robert Eachus
2017-01-24 21:08     ` Randy Brukardt

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