From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa2.mentor.iphmx.com (esa2.mentor.iphmx.com [68.232.141.98]) by sourceware.org (Postfix) with ESMTPS id 8EA223835547; Wed, 14 Dec 2022 07:57:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8EA223835547 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com X-IronPort-AV: E=Sophos;i="5.96,243,1665475200"; d="scan'208";a="90159396" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa2.mentor.iphmx.com with ESMTP; 13 Dec 2022 23:57:39 -0800 IronPort-SDR: gpCSZxHGKb6ZF7WQUNqsHy0DKXqu29WMx7aKKXEahlfeIj+N/cjaIe8QnS4t1w0jAJFnjoRs1Q dYBcPXmE+yf7j4whPbisTAYVW6UDwFaOviucJHZVAB1/qCBunjbucLY68AYJZOC0TRb8pv+Ani mvqknW8QcqC1w13/0UXCvRn1XpRGjyVxuBMW5V+0ceMPcOJHR53QYyyfN1ncNKUs0QfD1b9qmF 5e/dk1te5iL57FNExnncMfIyYJbzTDePif40D3CHP8UQSTB1cwEGM600+50JOXQi9Y2mseS+Zg xG4= Message-ID: <86a8d0f0-e3e3-3abe-f024-149615d2af4b@codesourcery.com> Date: Wed, 14 Dec 2022 08:57:31 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 Subject: Re: [Patch, Fortran] libgfortran's ISO_Fortran_binding.c: Use GCC11 version for backward-only code [PR108056] Content-Language: en-US To: Harald Anlauf , gcc-patches , fortran References: <1faf5680-9f5a-1f9d-4a9d-4eaff8982056@codesourcery.com> From: Tobias Burnus In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: quoted-printable X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-15.mgc.mentorg.com (139.181.222.15) To svr-ies-mbx-12.mgc.mentorg.com (139.181.222.12) X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,NICE_REPLY_A,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi Harald, On 13.12.22 23:27, Harald Anlauf wrote: > Am 13.12.22 um 22:41 schrieb Tobias Burnus: >> Back to differences: 'diff -U0 -p -w' against the last GCC 11 branch >> shows: >> >> ... >> @@ -35,0 +37,2 @@ export_proto(cfi_desc_to_gfc_desc); >> +/* NOTE: Since GCC 12, the FE generates code to do the conversion >> + directly without calling this function. */ >> @@ -63 +66 @@ cfi_desc_to_gfc_desc (gfc_array_void *d, >> - d->dtype.version =3D s->version; >> + d->dtype.version =3D 0; > > I was wondering what the significance of "version" is. > In ISO_Fortran_binding.h we seem to always have > #define CFI_VERSION 1 > and it did not change with gcc-12. The version is 1 for CFI but it is 0 for GFC. However, as we do not check the GFC version anywhere and it is not publicly exposed, it does not really matter. Still, "d->dtype.version =3D 0;" matches what the compiler itself produces =E2=80=93 and for consistency, setting it to 0 is better than setting it to 1 (via CFI's version field). Actually 'dtype.version' is not really set anywhere; at least gfc_get_dtype_rank_type(...) does not set it; zero initialization is most common but it could be also some random value. In libgfortran, GFC_DTYPE_CLEAR explicitly sets it to 0. >> @@ -100,2 +110,2 @@ gfc_desc_to_cfi_desc (CFI_cdesc_t **d_pt >> - d =3D malloc (sizeof (CFI_cdesc_t) >> - + (CFI_type_t)(CFI_MAX_RANK * sizeof (CFI_dim_t))); >> + d =3D calloc (1, (sizeof (CFI_cdesc_t) >> + + (CFI_type_t)(CFI_MAX_RANK * sizeof (CFI_dim_t)))); >> @@ -107 +117 @@ gfc_desc_to_cfi_desc (CFI_cdesc_t **d_pt >> - d->version =3D s->dtype.version; >> + d->version =3D CFI_VERSION; > > This treatment of "version" was the equivalent to the above that > confused me. Assuming we were to change CFI_VERSION in gcc-13+, > is this the right choice here regarding backward compatibility? I don't think we will change CFI version any time soon as we rather closely follow the Fortran standard and I do not see any changes which are required there. NOTE: As s->dtype.version is either 0 or some random value, setting version in the CFI / ISO C descriptor to 1, be it as literal or as macro constant, makes it the same as CFI_VERSION. And: I don't think we will change CFI_VERSION or the structure of the CFI array descriptor any time soon; there does not seem to be any need for it, it matches the Fortran standard one well (and no plans seem to be planed on that side) and, finally, changing an array descriptor is painful! However, using '1; /* CFI_VERSION in GCC 11 and at time of writing. */' would also work =E2=80=93 but I would expect that we will go through all CF= I users if we ever change the descriptor (and bump the version), possibly adding version-number dependent code. > So besides the "version" question ok from my side. I hope I could answer the latter. Tobias ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstra=C3=9Fe 201= , 80634 M=C3=BCnchen; Gesellschaft mit beschr=C3=A4nkter Haftung; Gesch=C3= =A4ftsf=C3=BChrer: Thomas Heurung, Frank Th=C3=BCrauf; Sitz der Gesellschaf= t: M=C3=BCnchen; Registergericht M=C3=BCnchen, HRB 106955