TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy

TEAM-ADA@LISTSERV.ACM.ORG

Options: Use Classic View

Use Monospaced Font
Show HTML 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)
John:

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>

13.9(15):

   "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.

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

ATOM RSS1 RSS2