[PATCH v2] ada: Simplify code while building boolean expression

Samuel Tardieu sam@rfc1149.net
Thu Aug 7 14:23:00 GMT 2008


On  7/08, Arnaud Charlet wrote:

| > | (This v2 further simplifies the code by converting only the
| > | result to "Boolean")
| > | 
| > | Simplify code by building
| > | 
| > |   if Boolean (B'First and B'Last) then
| > | 
| > | instead of
| > | 
| > |   if B'First = BT (True) and B'Last = BT (True) then
| > | 
| > | in Silly_Boolean_Array_Xor_Test.
| > 
| > Arnaud, I'm not sure about this one: if B is defined as a null range
| > (True..False), then "B'First and B'Last" doesn't fall into B domain. The
| > first version may be better in fact, I'll let you choose.
| 
| Well for sure you are not helping the review process by sending many
| follow ups and changes.
| 
| I'll see what I can do.

The first version is definitely the one to keep.

Note that the checks in question (Silly_Boolean_Array_*) are here to
handle pathological cases, but their presence make even more pathological
cases to fail: the following test raises Constraint_Error while it should
not. The "Silly_Boolean_Array_*" checks should be completed by bound
checks, which will also be suppressed in most cases.

--
procedure Bogus is
   type B is new Boolean range True .. True;
   type B_A is array (1 .. 0) of B;
   A1, A2 : B_A := (others => True);
   A3 : B_A;
begin
   A3 := A1 xor A2;
end Bogus;



More information about the Gcc-patches mailing list