From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Date: 4 Sep 93 00:13:10 GMT From: slinky.cs.nyu.edu!slinky.cs.nyu.edu!nobody@nyu.edu (Robert Dewar) Subject: Re: Unchecked_Conversion question Message-ID: <268mim$28v@schonberg.cs.nyu.edu> List-Id: Wes makes an incorrect assumption that a compiler is not free to assume that the output of unchecked conversion is valid. Since a program execution is erroneous if the value is not valid, the compiler is free to do anything it wants in this case, and in particular it can skip the check which seems to be otherwise required. It is this same freedom which allows A:= B to skip a check if A and B are the same subtype. The check is required by the RM even in the case of the values being the same subtype (that's because the value of B is just a value of the base type, and assignment to A always requires a check that the value of the base type meets its constraints). The only case however if the subtypes are the same, where the check could really be needed is if B is uninitialized, but then the program is erroneous anyway, so the compiler can omit the check (and most all compilers do in this case, maybe all). Ada 9X cleans up a lot of these issues with its introduction of the notion of a bounded error. This is an error which is not necesssarily detected, but unlike the erronoues case, there are a limited set of consequences.