https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90539
--- Comment #22 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
I've been trying out some things, and I cannot construct a failing
test case.
A sane way to build such an interface would be
cat tst.f90
module x
use, intrinsic :: iso_c_binding, only : c_double
implicit none
interface
subroutine foo(a) bind(c)
import
real(kind=c_double) :: a(*)
end subroutine foo
end interface
private
public :: bar
contains
subroutine bar(a)
real(kind=c_double), dimension(:) :: a
a = 42._c_double
call foo(a)
end subroutine bar
end module x
program main
use, intrinsic :: iso_c_binding, only : c_double
use x
implicit none
real(kind=c_double), dimension(1) :: a
call bar(a)
end program main
$ cat foo.c
#include <stdio.h>
void foo (double *a)
{
printf("%f\n", *a);
}
$ gfortran -flto -O tst.f90 foo.c
$ ./a.out
42.000000
This works as expected.
What I do not understand is (comment #17)
(gdb) p debug(fsym)
|| symbol: '_formal_107'
type spec : (REAL 8)
attributes: (VARIABLE DIMENSION DUMMY)
Array spec:(0 [0])
This means that the dummy parameter has rank zero. How, then,
is it possible to pass a rank-1 argument to it?
(gdb) p debug(expr)
nf90_put_var_1d_eightbytereal:values(FULL) (REAL 8)
(gdb) p *expr->ref
$8 = {
type = REF_ARRAY,
u = {
ar = {
type = AR_FULL,
dimen = 1,
codimen = 0,
Something very fishy going on here.
Please look up the Fortran interface to the C function that is called,
nc_put_vara_double.
Also, please break on gfc_conv_procedure_call for the call
in question and do
$ call debug(sym)
$ p args
$ call debug(args->expr)
$ p args->next
$ call debug(args->next->expr)
... and so on, until args->...->next becomes a null pointer.
I am starting do suspect that this is, in fact, another piece of SPEC
bugware where they made some sort of broken interface between C
and Fortran, which is exposed by my patch.
Hmpf...