incorrect integer kind returned from call to storage_size() with gcc 4.9.0
Rezny, Mike
mike.rezny@metoffice.gov.uk
Fri Jul 25 13:29:00 GMT 2014
Hi Nick,
thanks for the quick response.
Here is the output from your program:
As you can see, storage_size is not returning KIND(0).
Sorry, I still keep talking in terms of hardware implementation (32-, 64-bi=
t) when I should be talking in Fortran KINDS.
$ cat test2.f90
PROGRAM Test2
USE ISO_FORTRAN_ENV
IMPLICIT NONE
INTEGER, PARAMETER :: k =3D SELECTED_INT_KIND(18)
PRINT *, KIND(0), k, KIND(STORAGE_SIZE(0.0))
PRINT *, SIZEOF(0), SIZEOF(0_k), SIZEOF(STORAGE_SIZE(0.0))
END PROGRAM Test2
$ gfortran -c test2.f90
$ gfortran -o test2 test2.o
$ ./test2
4 8 8
4 8 8
This is a cut down problem which manifested itself in passing a storage siz= e into an assert clause in PfUnit.
Assert is polymorphic and the compiler will not accept the returned kind of= storage_size as one of the implemented interfaces although it is quite hap= py with similar functions such as precision() and range() which do return a= n integer of default kind.
There is probably also a third issue. storage_size is returning an integer =
KIND=3D8 and the compiler should issue a warning if an attempt is made to c= onvert from an integer of kind=3D8 to an integer of kind=3D4. There is no w= arning issued when compiling with -Wall as would be reported in a normal at= tempt at such an assignment:
integer (8) :: i =3D 45
integer (4) :: j
j =3D i
j =3D storage_size(0.0)
kindest regards
Mike
More information about the Fortran
mailing list