comp.lang.ada
 help / color / mirror / Atom feed
* Validity of renamed objects?
@ 2014-04-01 13:04 Jacob Sparre Andersen
  2014-04-01 13:44 ` J-P. Rosen
  2014-04-01 13:55 ` Markus Schöpflin
  0 siblings, 2 replies; 4+ messages in thread
From: Jacob Sparre Andersen @ 2014-04-01 13:04 UTC (permalink / raw)


I've been reading section 8.5.1 in the LRM, and I can't figure out when
the compiler is supposed to check the validity of a renamed object.

An example:

procedure Renaming_1 is
   Object  : String (1 .. 9) := "dead beef";
   Index   : Natural := 0;
   Renamed : Character renames Object (Index);
begin
   Index := (Object'First + Object'Last) / 2;
   if Renamed /= ' ' then
      raise Program_Error
        with "Expected Renamed to match the changed value of Index.";
   end if;
end Renaming_1;

1) Should I get a Constraint_Error when Renamed is declared?

2) What will the value of Renamed be after Index has been changed?

Greetings,

Jacob

PS: I know what the version of GNAT I have at hand does, but what it
    does is not completely obvious from my reading of the LRM.
-- 
»But you have to be a bit wary of a ship that collects
 snowflakes.«                                  -- Diziet Sma

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

end of thread, other threads:[~2014-04-01 18:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-01 13:04 Validity of renamed objects? Jacob Sparre Andersen
2014-04-01 13:44 ` J-P. Rosen
2014-04-01 13:55 ` Markus Schöpflin
2014-04-01 18:35   ` Jacob Sparre Andersen

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