ecmwf/fckit

Ambiguous interfaces in generic interface

DJDavies2 opened this issue · 3 comments

I am getting this compile failure:

[ 1%] Building Fortran object src/fckit/CMakeFiles/fckit.dir/fctest.F90.o
cd /home/david/src/oops-stuff/fckit/fckit-build/src/fckit && /home/david/installs/gcc/7.1.0/v1/bin/gfortran -Dfckit_EXPORTS -I/home/david/src/oops-stuff/fckit/fckit-build/module -I/home/david/src/oops-stuff/fckit/src -I/home/david/src/oops-stuff/fckit/fckit-build/src -I/home/david/src/oops-stuff/fckit/fckit-build/src/fckit -I/home/david/installs/oops-stuff/eckit/include -I/usr/include -I/home/david/installs/oops-stuff/eigen/include/eigen3 -I/home/david/installs/oops-stuff/mpich/include -fbacktrace -g -O3 -funroll-all-loops -finline-functions -J../../module -fPIC -c /home/david/src/oops-stuff/fckit/src/fckit/fctest.F90 -o CMakeFiles/fckit.dir/fctest.F90.o
/home/david/src/oops-stuff/fckit/src/fckit/fctest.F90:111:38:

subroutine fctest_check_equal_int32_r1(V1,V2,line)
1
/home/david/src/oops-stuff/fckit/src/fckit/fctest.F90:131:38:

subroutine fctest_check_equal_int64_r1(V1,V2,line)
2
Error: Ambiguous interfaces in generic interface 'fce' for ‘fctest_check_equal_int32_r1’ at (1) and ‘fctest_check_equal_int64_r1’ at (2)
make[2]: *** [src/fckit/CMakeFiles/fckit.dir/fctest.F90.o] Error 1

david@david-System-Product-Name ~/src/oops-stuff $ $HOME/installs/gcc/7.1.0/v1/bin/gfortran -v
Using built-in specs.
COLLECT_GCC=/home/david/installs/gcc/7.1.0/v1/bin/gfortran
COLLECT_LTO_WRAPPER=/home/david/installs/gcc/7.1.0/v1/libexec/gcc/i686-pc-linux-gnu/7.1.0/lto-wrapper
Target: i686-pc-linux-gnu
Configured with: /home/david/src/downloads/gcc-7.1.0/configure --prefix=/home/david/installs/gcc/7.1.0/v1 --enable-languages=all
Thread model: posix
gcc version 7.1.0 (GCC)

david@david-System-Product-Name ~/src/oops-stuff $ uname -a
Linux david-System-Product-Name 3.13.0-149-generic #199-Ubuntu SMP Thu May 17 10:12:57 UTC 2018 i686 athlon i686 GNU/Linux

I think this is because the generic interface FCE contains an "int32" version and an "int64" version where the int32 version declares the arguments as c_int and the int64 version declares the argument as c_long. However c_int and c_long are the same on this platform.

This crops up in quite a few places in fckit, the particular failure above is the first of many I think.

Thank you for reporting this.
The pull request #3 cannot be accepted, as it would break all other platforms where c_long is usually different from c_int.
I provide you asap with a fixed develop branch that should work for your platform

Thanks. I'm aware that on most platforms c_int is different to c_long, but those platforms will be unaffected because c_int will also be different to c_long_long. In fact on those platforms typically c_long and c_long_long will be the same. The only platforms where the fix will fail will be platform where c_long /= c_long_long, or where c_long_long is not defined. I'm not aware of any platforms likely to be targeted by something like fckit?

@DJDavies2 you are correct. I wrongly assumed long long would be 128 bits ( even though in theory it could be ).
Rather than count on platform dependent values, we can use c_int32_t and c_int64_t. I'll accept your PR. Thanks!