public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
From: Damian Rouson <rouson@lbl.gov>
To: Paul Richard Thomas <paul.richard.thomas@gmail.com>
Cc: "fortran@gcc.gnu.org" <fortran@gcc.gnu.org>
Subject: Re: Bug 104404 - Incorrect CFI_cdesc_t "type" member for assumed-type, assumed-rank complex dummy arguments
Date: Sun, 6 Feb 2022 04:11:04 -0800	[thread overview]
Message-ID: <CAM2rSoW4sSkYOvvhMMYMxoof5oTO7iVkWb=KjDx5KVgTXNwHyA@mail.gmail.com> (raw)
In-Reply-To: <CAGkQGiJXoDkYrrEBycuAC8BUL-Za+SDdLhfp0c3PecPVX1KEFQ@mail.gmail.com>

That's great news.  Thanks for letting me know.

Damian

On Sun, Feb 6, 2022 at 12:48 AM Paul Richard Thomas <
paul.richard.thomas@gmail.com> wrote:

> Hi Damian,
>
> Tobias Burnus fixed it in 12-branch:
> GNU Fortran (GCC) 12.0.1 20220203 (experimental)
> ./a.out
>  -----  complex(c_float_complex) --------
> a_desc->type = 1028
> a_desc->elem_len = 8
> CFI_type_float_Complex = 1028
> CFI_type_double_Complex = 2052
>  -----  complex(c_double_complex) -------
> a_desc->type = 2052
> a_desc->elem_len = 16
> CFI_type_float_Complex = 1028
> CFI_type_double_Complex = 2052
>
> Cheers
>
> Paul
>
>
> On Sun, 6 Feb 2022 at 03:39, Damian Rouson via Fortran <
> fortran@gcc.gnu.org> wrote:
>
>> 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
>>
>
>
> --
> "If you can't explain it simply, you don't understand it well enough" -
> Albert Einstein
>

      reply	other threads:[~2022-02-06 12:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-06  3:38 Damian Rouson
2022-02-06  8:48 ` Paul Richard Thomas
2022-02-06 12:11   ` Damian Rouson [this message]

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='CAM2rSoW4sSkYOvvhMMYMxoof5oTO7iVkWb=KjDx5KVgTXNwHyA@mail.gmail.com' \
    --to=rouson@lbl.gov \
    --cc=fortran@gcc.gnu.org \
    --cc=paul.richard.thomas@gmail.com \
    /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).