From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qt1-x835.google.com (mail-qt1-x835.google.com [IPv6:2607:f8b0:4864:20::835]) by sourceware.org (Postfix) with ESMTPS id 08B5B3858423 for ; Sun, 6 Feb 2022 08:48:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 08B5B3858423 Received: by mail-qt1-x835.google.com with SMTP id j12so9596394qtr.2 for ; Sun, 06 Feb 2022 00:48:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=6N6SIFMsVU9Yr/Fio/igcdc/GqfTZDnv192lPZor13w=; b=z+pYS7xpuFCYdjvLXWRiIF2Oqc4tFCNfnNx50gu3JOx0W92GjcADbH2scDVVVavYP9 dTO+0g+kjEmykOuipWcQGQsYry5da3g2Wwsyw2OsXNIVh0ht2Q09J1Do5vPZxnV+tzeN H0eHADd+yhjz1AUj7McpTDIF/lzCbJfR9o2RPO0dgyZzIMtozH+PNB+pRpLaoVb7NUhp cjw+ZGH+0K9sVy1q+gIj9D9en8pzECj8z9jGDc7lMSFc45N11P5bIqJVyviY5HEjJ07y QwfV1lQXkf5J4mKIubDRE9XDgSRkidc/7M/KfklbOCaEkBCETCFakbVFL1OKgL9Sa7jp AfRw== X-Gm-Message-State: AOAM532wcfrB+y5oL2ZEx9KzrX2kKgwo00F6VIOIY/RtmFpmgbbqTzqy 7YYDAWGIFltIByIidnXEk8polWsEjtfiqPx1GAI= X-Google-Smtp-Source: ABdhPJyuVBTBfJS/ZOqQH5sWtkuZPcSSO1grt3bSukcgJ0eC64fNLIbL9EOReeF4PEX9rcN4iOxHk0HjzV3Efs5Nicg= X-Received: by 2002:ac8:4e41:: with SMTP id e1mr4623204qtw.369.1644137326598; Sun, 06 Feb 2022 00:48:46 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Paul Richard Thomas Date: Sun, 6 Feb 2022 08:48:35 +0000 Message-ID: Subject: Re: Bug 104404 - Incorrect CFI_cdesc_t "type" member for assumed-type, assumed-rank complex dummy arguments To: Damian Rouson Cc: "fortran@gcc.gnu.org" X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, HTML_MESSAGE, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: fortran@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Fortran mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Feb 2022 08:48:48 -0000 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 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 > #include > > 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 > #include > > 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