Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iand with different kind parameters using new gfortran version

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?

like image 496
Javier Garcia Avatar asked Jan 15 '20 17:01

Javier Garcia


1 Answers

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.

like image 175
janneb Avatar answered Oct 22 '22 06:10

janneb