[PATCH] Fortran -- Handle BOZ in accordance with F2008/2015.
Dominique d'Humières
dominiq@lps.ens.fr
Sat Oct 7 10:37:00 GMT 2017
Thanks for working on the issue. While testing your patch I have found the following problems:
(1) Typo in gcc/fortran/array.c
+ /* If an array contains a BT_BOZ, then array elements need to be converted
+ an INTEGER. This is an GNU Fortran extension. Mixing BOZ and non-BOZ
missing ‘to’?
(2) Compiling
integer :: i = 1, j = 2
print *, ble(i,j), blt(z'ff',z'fa')
end
gives an ICE
f951: internal compiler error: in compare_bitwise, at fortran/simplify.c:1516
which is
gcc_assert (i->ts.type == BT_INTEGER);
gcc_assert (j->ts.type == BT_INTEGER);
(3) Compiling (variant of pr54072)
USE, INTRINSIC :: ISO_C_BINDING
IMPLICIT NONE
INTEGER, PARAMETER :: GLbitfield=C_INT
INTEGER(GLbitfield), PARAMETER :: GL_CURRENT_BIT = INT(z'00000001') ! 0x00000001
INTEGER(GLbitfield), PARAMETER :: GL_CLIENT_ALL_ATTRIB_BITS = &
transfer(z'ffffffff',GL_CURRENT_BIT) ! 0xffffffff
print *, GLbitfield, GL_CURRENT_BIT, GL_CLIENT_ALL_ATTRIB_BITS
END
gives an ICE
f951: internal compiler error: Invalid expression in gfc_element_size.
(4) Compiling
print *, INT(z'ffffffff',4)
end
gives
print *, INT(z'ffffffff',4)
1
Error: Arithmetic overflow converting INTEGER(-1) to INTEGER(4) at (1). This check can be disabled with the option '-fno-range-check’
Should not it be -1?
(5) Compiling
print *, real(z'ffffffff',4)
end
gives
print *, real(z'ffffffff',4)
1
Error: Arithmetic NaN converting REAL(4) to REAL(4) at (1). This check can be disabled with the option '-fno-range-check’
Why not a warning?
(6) Compiling
print *, storage_size(z'FFFFFFFF')
end
gives an ICE
f951: internal compiler error: Invalid expression in gfc_element_size.
The code is probably invalid, but I don’t know how to parse
> The processor shall allow the position of the leftmost nonzero bit to be at least z - 1,
> where z is the maximum value that could result from invoking the intrinsic function
> STORAGE_SIZE (13.8.175) with an argument that is a real or integer scalar of any kind
> supported by the processor.
Without the patch it returns 128 at run time.
Dominique
More information about the Fortran
mailing list