From: "G.B." <bauhaus@notmyhomepage.invalid>
Subject: Does object renaming allow the view to be a copy?
Date: Sun, 22 Jan 2017 09:27:44 +0100
Date: 2017-01-22T09:27:44+01:00 [thread overview]
Message-ID: <o61qau$ock$1@dont-email.me> (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
next reply other threads:[~2017-01-22 8:27 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-22 8:27 G.B. [this message]
2017-01-22 10:37 ` Does object renaming allow the view to be a copy? 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
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox