From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C2BF0392AC01; Mon, 12 Dec 2022 12:09:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C2BF0392AC01 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1670846973; bh=RoSsb5KnM50W+9mCQdR+5zI78uVaFISuZpV4kcEQqEI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=HO+ZrSY4btLKLLWcd5ZHdHkTtWSxneWhQg2AIWKBfpw2th9d00PQOISN0dt/Njwba M8j407q/vhaN5HHwPiU0qHRltaE9srO7dikjyQbrcxPzf5cAuDfSrqBox7e1pJ70hb kqGF1ofdLdYprIFEbvLCRiSOhxfnwZDqlyZELhgA= From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libfortran/108056] [12/13 Regression] backward compatibility issue between 11 and 12 Date: Mon, 12 Dec 2022 12:09:31 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libfortran X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: ABI X-Bugzilla-Severity: normal X-Bugzilla-Who: burnus at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.3 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D108056 --- Comment #12 from Tobias Burnus --- First, there were several issue in GCC 12 related to using CFI_. Thus, using GCC 12 is highly recommended. This can be seen when implementing the function using the following code (a= nd removing ', name=3D"sync"' - calling 'void sync(void)' system function): #include void bar_ts (CFI_cdesc_t *a, CFI_cdesc_t *b) { __builtin_printf ("a =3D %s, b =3D %s\n", (a->type =3D=3D CFI_type_float) ? "float" : "something else", (b->type =3D=3D CFI_type_float) ? "float" : "something else"); } This prints the expected value: a =3D float, b =3D float * * * In GCC 11, the value that arrives at type =3D GFC_DESCRIPTOR_TYPE (s); and is then used for d->type =3D (CFI_type_t)type; is BT_ASSUMED (=3D 11) instead of the expected BT_REAL (=3D 3), loosing the= data type. As d->type is now BT_ASSUMED and this case is not handled, we run into the code: switch (d->type) ... default: internal_error (NULL, "Invalid type in descriptor"); * * * I want to note that both functions, _gfortran_cfi_desc_to_gfc_desc _gfortran_gfc_desc_to_cfi_desc are only in GCC 12's libgfortran.so to provide backward compatibility with = GCC <=3D 11. Thus, we have two options: (A) We change those to functions back to the GCC 11 version; the new check = was added in Sandra's commit r12-3321-g93b6b2f614eb692d1d8126ec6cb946984a9d= 01d7 back when those functions were still used in GCC 12. (B) I think we have to possibilities to map this: BT_ASSUMED -> CFI_type_cptr or CFI_type_other; using the latter, that's t= he following (untested but it should work): ------------------------------------------- --- a/libgfortran/runtime/ISO_Fortran_binding.c +++ b/libgfortran/runtime/ISO_Fortran_binding.c @@ -182,4 +182,7 @@ gfc_desc_to_cfi_desc (CFI_cdesc_t **d_ptr, const gfc_array_void *s) d->type =3D CFI_type_struct; break; + case BT_ASSUME: + d->type =3D CFI_type_other; + break; case BT_VOID: /* FIXME: PR 100915. GFC descriptors do not distinguish between -------------------------------------------- Thoughts whether (A) or (B) is better? In any case, we should check whether the testcase of comment 0 plus the C c= ode above in this comment should be added as new testcase. But it might very well alread= y be covered in our testsuite.=