public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Paul Richard Thomas <paul.richard.thomas@gmail.com>
To: Tobias Burnus <tobias@codesourcery.com>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>, fortran <fortran@gcc.gnu.org>
Subject: Re: [Patch, Fortran] PR91863 - fix call to bind(C) with array descriptor
Date: Sun, 27 Oct 2019 08:08:00 -0000	[thread overview]
Message-ID: <CAGkQGiJ5WUvpidmcJDdAHTz27v4cJRv=j0=mOZnuogtrfGJV-g@mail.gmail.com> (raw)
In-Reply-To: <9dc15d5a-5f80-a5fa-67a0-9d633f0e6923@codesourcery.com>

Hi Tobias,

Thanks for taking care of this. OK for trunk and 9-branch.

Cheers

Paul

On Wed, 23 Oct 2019 at 14:07, Tobias Burnus <tobias@codesourcery.com> wrote:
>
> With the trunk, there are three issues:
>
> (a) With bind(C), the callee side handles deallocation with intent(out).
>
> This should produce the code:
>      if (cfi.0 != 0B)
>        {
>          __builtin_free (cfi.0);
>          cfi.0 = 0B;
>        }
> This fails as cfi.0 (of type 'void*') is dereferenced and
> *cfi.0 = 0B' (i.e. assignment of type 'void') causes the ICE.
>
>
> (b) With that fixed, one gets:
>      sub (cfi.4);
>      _gfortran_cfi_desc_to_gfc_desc (&a, &cfi.4);
>      if (cfi.4 != 0B)
>        __builtin_free (cfi.4);
>      ... code using "a" ...
> That also won't shine as 'a.data' == 'cfi.4'; hence, one
> accesses already freed memory.
>
> I don't see whether freeing the cfi memory makes sense at all;
> as I didn't come up with a reason, I removed it for good.
>
>
> Those issues, I have solved. The third issue is now PR fortran/92189:
> (c) When allocating memory in a Fortran-written Bind(C) function, the
> shape/bounds changes are not propagated back to Fortran.
> Namely, "sub" lacks some _gfortran_gfc_desc_to_cfi_desc call at the end!
>
> The issue pops up, if you change 'dg-do compile' into 'dg-do run'. For
> using a C-written function, that's a non-issue. Hence, it makes sense
> to fix (a)+(b) of the bug separately.
>
>
> OK for the trunk and GCC 9? (At least the ICE is a regression.)
>
> Tobias
>


-- 
"If you can't explain it simply, you don't understand it well enough"
- Albert Einstein

      parent reply	other threads:[~2019-10-27  7:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-23 13:21 Tobias Burnus
2019-10-26 19:20 ` *Early ping* " Tobias Burnus
2019-10-27  8:08 ` Paul Richard Thomas [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='CAGkQGiJ5WUvpidmcJDdAHTz27v4cJRv=j0=mOZnuogtrfGJV-g@mail.gmail.com' \
    --to=paul.richard.thomas@gmail.com \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=tobias@codesourcery.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).