Download HP Pascal for OpenVMS Language Reference Manual

Transcript
Usage and Default Information:
•
You can apply this attribute to variables, formal parameters, formal
discriminants, the base types of pointer variables, components of structured
variables, function results, and the types of other data items listed in
Table 10–9.
•
A conformant VARYING parameter or a formal schema parameter cannot
be declared UNSAFE.
•
UNSAFE is the only attribute allowed on schema formal discriminants.
•
An expression of any type is assignment compatible with an unsafe
object. However, neither the expression nor the object can contain a
file component. If the machine representations of the expression and the
unsafe object differ, the compiler forces them to have the same number of
bits by modifying the value of the expression as follows:
Assignment to a variable with the UNSAFE attribute causes the value
of the right-hand side to be truncated or zero-extended to the bit size of
the left-hand variable. Note this can not always be its natural bit size;
for example, if the variable you are assigning a value to was declared
with an explicit size attribute. If that value is the legal value of the
left-hand type, then the assignment occurs; otherwise, the variable is
undefined.
The UNSAFE attribute has no effect on variable fetches.
Consider the following example:
v : [LONG, UNSAFE] ( aa, bb, cc );
As an enumeration of less than 256 elements, its natural size can be
less than a longword. Because of the LONG attribute, it is allocated
a longword in memory. However, fetches from the variable might be
smaller because the explicit size attribute has no effect on any fetches.
Assignments correctly assign the natural size portion of V, but the contents
of the extra bits are zero-extended at the assignment.
•
A pointer expression is assignment compatible with a pointer variable
whose base type is unsafe only if the base types have the same allocation
size and if they have compatible alignment, READONLY, VOLATILE, and
WRITEONLY attributes.
•
You can pass an actual parameter variable to an unsafe formal VAR
parameter if the types have the same allocation size and if they have
compatible alignment, READONLY, VOLATILE, and WRITEONLY
attributes.
Attributes 10–43