comp.lang.ada
 help / color / mirror / Atom feed
From: Jacob Sparre Andersen <jacob@jacob-sparre.dk>
Subject: Validity of renamed objects?
Date: Tue, 01 Apr 2014 15:04:58 +0200
Date: 2014-04-01T15:04:58+02:00	[thread overview]
Message-ID: <871txhmc91.fsf@adaheads.sparre-andersen.dk> (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

             reply	other threads:[~2014-04-01 13:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-01 13:04 Jacob Sparre Andersen [this message]
2014-04-01 13:44 ` Validity of renamed objects? J-P. Rosen
2014-04-01 13:55 ` Markus Schöpflin
2014-04-01 18:35   ` Jacob Sparre Andersen
replies disabled

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