public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "burnus at gcc dot gnu.org" <gcc-bugzilla@gcc.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	[thread overview]
Message-ID: <bug-108056-4-B4a3NdQtKE@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-108056-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108056

--- Comment #12 from Tobias Burnus <burnus at gcc dot gnu.org> ---
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 (and
removing ', name="sync"' - calling 'void sync(void)' system function):

#include <ISO_Fortran_binding.h>
void bar_ts (CFI_cdesc_t *a, CFI_cdesc_t *b) {
 __builtin_printf ("a = %s, b = %s\n",
   (a->type == CFI_type_float) ? "float" : "something else",
   (b->type == CFI_type_float) ? "float" : "something else");
}


This prints the expected value:
   a = float, b = float

 * * *

In GCC 11, the value that arrives at

  type = GFC_DESCRIPTOR_TYPE (s);

and is then used for

      d->type = (CFI_type_t)type;

is BT_ASSUMED (= 11) instead of the expected BT_REAL (= 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
<= 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-g93b6b2f614eb692d1d8126ec6cb946984a9d01d7
    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 the
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 = CFI_type_struct;
       break;
+    case BT_ASSUME:
+      d->type = 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 code
above in
this comment should be added as new testcase. But it might very well already be
covered
in our testsuite.

  parent reply	other threads:[~2022-12-12 12:09 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-11  6:37 [Bug libfortran/108056] New: " gilles.gouaillardet at gmail dot com
2022-12-11  7:05 ` [Bug libfortran/108056] " kargl at gcc dot gnu.org
2022-12-11  7:44 ` gilles.gouaillardet at gmail dot com
2022-12-11  7:51 ` gilles.gouaillardet at gmail dot com
2022-12-11  8:44 ` rimvydas.jas at gmail dot com
2022-12-11 13:19 ` [Bug libfortran/108056] [12/13 Regression] " rguenth at gcc dot gnu.org
2022-12-11 18:34 ` kargl at gcc dot gnu.org
2022-12-11 22:15 ` sandra at gcc dot gnu.org
2022-12-11 22:24 ` jakub at gcc dot gnu.org
2022-12-12  8:40 ` jakub at gcc dot gnu.org
2022-12-12  9:07 ` rguenther at suse dot de
2022-12-12  9:10 ` gilles.gouaillardet at gmail dot com
2022-12-12 12:09 ` burnus at gcc dot gnu.org [this message]
2022-12-12 12:34 ` rguenther at suse dot de
2022-12-15 11:27 ` cvs-commit at gcc dot gnu.org
2022-12-16  2:47 ` haochen.jiang at intel dot com
2022-12-16  7:48 ` burnus at gcc dot gnu.org
2022-12-16  7:57 ` cvs-commit at gcc dot gnu.org
2022-12-20 17:22 ` jakub at gcc dot gnu.org
2022-12-21  7:13 ` [Bug libfortran/108056] [12 " rguenth at gcc dot gnu.org
2022-12-21  7:23 ` cvs-commit at gcc dot gnu.org
2022-12-21  7:34 ` rguenth at gcc dot gnu.org

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=bug-108056-4-B4a3NdQtKE@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).