comp.lang.ada
 help / color / mirror / Atom feed
From: Jeffrey Carter <jrcarter@acm.org>
Subject: Re: When to do a constraint check and not ??
Date: Fri, 26 Oct 2001 23:44:29 GMT
Date: 2001-10-26T23:44:29+00:00	[thread overview]
Message-ID: <3BD9F556.CE3E522D@acm.org> (raw)
In-Reply-To: 3BD91EF8.EEB7EDBA@systems.saab.se

Per Sandberg wrote:
> 
> Assume the folowing code:
> 
> procedue bla is
>         b : boolean; --< B may contain any bit pattern at this point.
> 
>         procedure test( p : in out boolean ) is
>         begin
>                 b := false;
>         end test;
> 
> begin
>         test(b); --<< Is the compiler allowed to insert a constraint check on b
> here ??
> end;
> 
> Is the answer that it is up to the wendor.
> I did not get any clues from the LRM.

The answer is that you have incorrectly specified the parameter mode of
P in Test. Since you do not reference the in value of P, the mode should
be out.

The compiler is required to insert a constraint check on B if it has a
subtype different from P, see 6.4.1(11). The subtype conversion and
assignment mentioned require a range check, just as if you did them
manually.

In this case B and P have the same subtype, so the compiler may assume
the value of B is valid for the subtype and eliminate the range check.
However, it is not required to eliminate the check, so the above appears
to be a bounded error.

-- 
Jeff Carter
"I wave my private parts at your aunties."
Monty Python & the Holy Grail



  parent reply	other threads:[~2001-10-26 23:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-10-26  8:29 When to do a constraint check and not ?? Per Sandberg
2001-10-26 12:01 ` Peter Hend�n
2001-10-26 13:57 ` DuckE
2001-10-26 14:18 ` Ted Dennison
2001-10-26 23:44 ` Jeffrey Carter [this message]
2001-11-01 17:54 ` Tucker Taft
2001-11-02  3:44   ` Robert Dewar
2001-11-05 10:02 ` Peter Amey
replies disabled

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