Data type issues in ICB interfaces
Expected behavior
The ICB wrappers should correctly pass arguments such as rvec to
the Fortran routines.
Actual behavior
logical(kind=c_bool) and logical are not compatible types on e.g. gcc/gfortran 9,
in particular having different sizes (1 byte vs. 4 bytes).
As a consequence, it breaks passing rvec=false to the Fortran routines, because
the larger data type accesses some garbage on stack and becomes nonzero.
Where/how to reproduce the problem
- arpack-ng: 8a46621
- OS: fedora
- compiler: gcc/gfortran 9.1.1
- configure: ./configure --enable-icb
Steps to reproduce the problem
You can step from dseupd_c to dseupd in icb_arpack_c using gdb and see rvec is not correctly passed.
Or, like so:
set -e
git clone --depth 1 https://github.com/opencollab/arpack-ng.git tmp
cd tmp
# add print+exit statement to beginning of dseupd.f, just for simple illustration
sed -i -e "s/msglvl = mseupd/write(*,*) 'dseupd rvec =', rvec\n stop/" SRC/dseupd.f
# call via ICB
cat <<__EOF__ > testbug.c
#include <stdbool.h>
#include "arpack.h"
int main() {
bool rvec = false;
dseupd_c(rvec, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
return 0;
}
__EOF__
./bootstrap
./configure --enable-icb
make -j6
gcc -IICB -I. -o testbug testbug.c SRC/.libs/libarpack.a -llapack -lblas -lgfortran -lm
echo "The following should print rvec = .false."
./testbug
which prints here
The following should print rvec = .false.
dseupd rvec = T
OK, far from home. I'll try to have a look when possible. Did you try with several compiler / version ?
Pb fixed: closing issue.