From: Damian Rouson <rouson@lbl.gov>
To: fortran@gcc.gnu.org
Subject: Bug 104404 - Incorrect CFI_cdesc_t "type" member for assumed-type, assumed-rank complex dummy arguments
Date: Sat, 5 Feb 2022 19:38:55 -0800 [thread overview]
Message-ID: <CAM2rSoU=mQRq5ADnzB2MXrqGF+bD9VkGCB89RrAcQ34kAw=owQ@mail.gmail.com> (raw)
For an assumed-type, assumed-rank complex dummy argument in a C interface,
gfortran 11.2.0 passes a CFI_cdesc_t object with a "type" member that does
not match the corresponding CFI_type_float_Complex and
CFI_type_double_Complex values. In the case of a complex(c_float_complex)
argument, the passed "type" member corresponds to CFI_type_double_Complex.
For a complex(c_double_complex) argument, the "type" member has a value
that I don't recognize. Does anyone know whether this has been fixed on
the 12 branch?
% cat c_descriptor.c
#include <stdio.h>
#include <ISO_Fortran_binding.h>
void c_descriptor(CFI_cdesc_t* c)
{
printf("a_desc->type = %d \n", c->type);
printf("a_desc->elem_len = %d \n", c->elem_len);
printf("CFI_type_float_Complex = %d \n", CFI_type_float_Complex);
printf("CFI_type_double_Complex = %d \n", CFI_type_double_Complex);
}
% cat c_descriptor.c
#include <stdio.h>
#include <ISO_Fortran_binding.h>
void c_descriptor(CFI_cdesc_t* c)
{
printf("a_desc->type = %d \n", c->type);
printf("a_desc->elem_len = %d \n", c->elem_len);
printf("CFI_type_float_Complex = %d \n", CFI_type_float_Complex);
printf("CFI_type_double_Complex = %d \n", CFI_type_double_Complex);
}
(base) rouson@CLaSS adhoc % cat assumed-type.f90
module c_descriptor_m
implicit none
contains
module subroutine print_type_info(a)
type(*), intent(inout), contiguous, target :: a(..)
interface
subroutine c_descriptor(a) bind(C)
implicit none
type(*) a(..)
end subroutine
end interface
call c_descriptor(a)
end subroutine
end module
use c_descriptor_m
use iso_c_binding
implicit none
complex(c_float_complex) :: z_float = (0._c_float, 0._c_float)
complex(c_double_complex):: z_double = (0._c_double, 0._c_double)
print*, "----- complex(c_float_complex) --------"
call print_type_info(z_float)
print*, "----- complex(c_double_complex) -------"
call print_type_info(z_double)
end
% gfortran c_descriptor.c assumed-type.f90
% ./a.out
----- complex(c_float_complex) --------
a_desc->type = 2052
a_desc->elem_len = 8
CFI_type_float_Complex = 1028
CFI_type_double_Complex = 2052
----- complex(c_double_complex) -------
a_desc->type = 4100
a_desc->elem_len = 16
CFI_type_float_Complex = 1028
CFI_type_double_Complex = 2052
% gfortran --version
GNU Fortran (Homebrew GCC 11.2.0_3) 11.2.0
next reply other threads:[~2022-02-06 3:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-06 3:38 Damian Rouson [this message]
2022-02-06 8:48 ` Paul Richard Thomas
2022-02-06 12:11 ` Damian Rouson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAM2rSoU=mQRq5ADnzB2MXrqGF+bD9VkGCB89RrAcQ34kAw=owQ@mail.gmail.com' \
--to=rouson@lbl.gov \
--cc=fortran@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).