I am currently working with old code, that calls the iand
function with integers of different kinds as arguments. Here's a small example of what the code includes:
program test
integer*1 i
integer j, k
i = 1
j = 8
k = iand(i, j)
print *, k
end program test
gfortran versions 8 and earlier had as an extension the ability to call iand with integers of different kind (see, for instance, here), whereas this option was removed in gfortran 9 (see this site). For instance, with gfortran 7.5.0:
gfortran-7 -o test test.f90 && ./test
0
But when compiling with gfortran 9.2.0, I get:
gfortran -o test test.f90
...
Error: Arguments of ‘iand’ have different kind type parameters at (1)
Is there an option for the new version of gfortran
to let me use this code as is?
No, there isn't. This extension was removed as the semantics weren't well specified, and fixing the code to be standard conforming is simple.
See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81509
In your case, something like
k = iand(int(i, kind(j)), j)
is hopefully what you're after.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With