TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy


Options: Use Classic View

Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Topic: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Jacob Sparre Andersen <[log in to unmask]>
Fri, 16 Feb 2001 14:31:50 +0100
TEXT/PLAIN (44 lines)

If I am not mistaken, then the compilers are allowed to
assume that the result of an unchecked conversion results in
valid data.

> When I run the program, on both Green Hills and
> ObjectAda, with the pragma Suppress commented out, a
> Constraint_Error is raised on the line:
>     ZZZ_Control_Data := (Date => (Date, (Month => Control_Data.Month)));

So the problem is:

> begin
>     Control_Data     := To_Request_Block (Input_Data);

Ahh, Control_Data is assigned a valid value.

>     ZZZ_Control_Data := (Date => (Date, (Month => Control_Data.Month)));

No problem at all, the subtypes match, so we don't have to
waste time checking for constraint errors.

<looking in the LRM>


   "The implementation should not generate unnecessary
    run-tme checks to ensure that the representation of S is
    a representation of the target type. ..."

So you might argue that GreenHills and ObjectAda are wrong,
but since they don't check, but just stay aware that the
data may not be a valid representation of the type, the
situation is a bit tricky.

"There are only two types of data:
                         Data which has been backed up
                         Data which has not been lost - yet"