Next: Real array indices, Previous: I/O item lists, Up: Extensions
As an extension, GNU Fortran allows hexadecimal BOZ literal constants to
be specified using the X prefix, in addition to the standard Z prefix.
BOZ literal constants can also be specified by adding a suffix to the
string. For example, Z'ABC'
and 'ABC'Z
are equivalent.
The Fortran standard restricts the appearance of a BOZ literal constant
to the DATA
statement, and it is expected to be assigned to an
INTEGER
variable. GNU Fortran permits a BOZ literal to appear in
any initialization expression as well as assignment statements.
Attempts to use a BOZ literal constant to do a bitwise initialization of
a variable can lead to confusion. A BOZ literal constant is converted
to an INTEGER
value with the kind type with the largest decimal
representation, and this value is then converted numerically to the type
and kind of the variable in question. Thus, one should not expect a
bitwise copy of the BOZ literal constant to be assigned to a REAL
variable.
Similarly, initializing an INTEGER
variable with a statement such
as DATA i/Z'FFFFFFFF'/
will produce an integer overflow rather
than the desired result of -1 when i
is a 32-bit integer
on a system that supports 64-bit integers. The `-fno-range-check'
option can be used as a workaround for legacy code that initializes
integers in this manner.