https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93308
Bug ID: 93308 Summary: bind(c) subroutine changes lower bound of array argument in caller Product: gcc Version: 9.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: r.j.hogan at reading dot ac.uk Target Milestone: --- Created attachment 47670 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=47670&action=edit Self contained source file that demonstrates the bug When the attached program is compiled and run, the allocatable array has its lbound changed from 1 to 0 when it returns from the bind(c) routine, while the explicit-shape array does not. This can be seen from the output line: After call: lbound(A) = 0 , A(1) = 2.00000000 Correct behaviour (the lbound is not changed) is found when the same code is compiled using gfortran 8.3.0 or earlier, or using the Intel Fortran compiler. Note that all versions of gfortran I have used issue the following warning, whether or not their behaviour is correct: Warning: Variable ‘v’ at (1) is a dummy argument of the BIND(C) procedure ‘routine_bindc’ but may not be C interoperable [-Wc-binding-type] This bug is unfortunate because as far as I can see the other Fortran-2018 aspects of passing arrays to and from C/C++ work well. Thanks, Robin Hogan. $ gfortran -v Using built-in specs. COLLECT_GCC=gfortran COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none:hsa OFFLOAD_TARGET_DEFAULT=1 Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.2.1-9ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 9.2.1 20191008 (Ubuntu 9.2.1-9ubuntu2)