public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libfortran/101310] New: Bind(C): CFI_section seems confused by pointer arrays
@ 2021-07-03 20:48 sandra at gcc dot gnu.org
  2021-07-17 20:35 ` [Bug libfortran/101310] " sandra at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: sandra at gcc dot gnu.org @ 2021-07-03 20:48 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 101310
           Summary: Bind(C): CFI_section seems confused by pointer arrays
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libfortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sandra at gcc dot gnu.org
  Target Milestone: ---

Many of the unit tests for CFI_section included in the WIP TS 29113 testsuite
are failing.

https://gcc.gnu.org/pipermail/gcc-patches/2021-July/574115.html

At least some of the problems seem to be related to handling pointer arrays
where the lower bound may be nonzero; e.g. section-1p and section-2p fail, but
the corresponding non-pointer cases sharing the same C code pass.

The set of tests that seem affected by this bug are:

library/section-1p.f90
library/section-2p.f90
library/section-3.f90
library/section-3p.f90

and also

interoperability/fc-out-descriptor-7.f90

which tries to pass the result of CFI_section back to Fortran via an
intent(out) argument (the unit tests only manipulate it in C code).

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libfortran/101310] Bind(C): CFI_section seems confused by pointer arrays
  2021-07-03 20:48 [Bug libfortran/101310] New: Bind(C): CFI_section seems confused by pointer arrays sandra at gcc dot gnu.org
@ 2021-07-17 20:35 ` sandra at gcc dot gnu.org
  2021-07-18  5:54 ` sandra at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: sandra at gcc dot gnu.org @ 2021-07-17 20:35 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from sandra at gcc dot gnu.org ---
Looks like 3 bugs for the price of 1!

First off the loop to fill in the result dimensions in CFI_section seemed to be
applying the base adjustment twice in different ways, or something like that. 
I've rewritten and simplified that code.

The section-3 and section-3p test cases were themselves buggy.  I swear I fixed
one of bugs before but I must have discarded that change along with some failed
experiments/debugging code for the bug above.

Finally, fc-out-descriptor-7 was failing because it uses the same pointer array
as both source and result, and CFI_section was messing with the dimensions in
result before computing the base address adjustment from source.  This ended up
not having anything to do with the result array being intent(out).

I'm going to add some more test cases and regression-test before posting the
patch, but I do have fixes for all 3 bugs now.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libfortran/101310] Bind(C): CFI_section seems confused by pointer arrays
  2021-07-03 20:48 [Bug libfortran/101310] New: Bind(C): CFI_section seems confused by pointer arrays sandra at gcc dot gnu.org
  2021-07-17 20:35 ` [Bug libfortran/101310] " sandra at gcc dot gnu.org
@ 2021-07-18  5:54 ` sandra at gcc dot gnu.org
  2021-07-28  4:25 ` cvs-commit at gcc dot gnu.org
  2021-07-28 20:22 ` sandra at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: sandra at gcc dot gnu.org @ 2021-07-18  5:54 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from sandra at gcc dot gnu.org ---
Patch posted here:

https://gcc.gnu.org/pipermail/fortran/2021-July/056251.html

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libfortran/101310] Bind(C): CFI_section seems confused by pointer arrays
  2021-07-03 20:48 [Bug libfortran/101310] New: Bind(C): CFI_section seems confused by pointer arrays sandra at gcc dot gnu.org
  2021-07-17 20:35 ` [Bug libfortran/101310] " sandra at gcc dot gnu.org
  2021-07-18  5:54 ` sandra at gcc dot gnu.org
@ 2021-07-28  4:25 ` cvs-commit at gcc dot gnu.org
  2021-07-28 20:22 ` sandra at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-07-28  4:25 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Sandra Loosemore <sandra@gcc.gnu.org>:

https://gcc.gnu.org/g:b4a9bc7856ee1d3ff98b04402334a362540af2cf

commit r12-2554-gb4a9bc7856ee1d3ff98b04402334a362540af2cf
Author: Sandra Loosemore <sandra@codesourcery.com>
Date:   Sat Jul 17 16:12:18 2021 -0700

    Bind(c): Fix bugs in CFI_section

    CFI_section was incorrectly adjusting the base pointer for the result
    array twice in different ways.  It was also overwriting the array
    dimension info in the result descriptor before computing the base
    address offset from the source descriptor, which caused problems if
    the two descriptors are the same.  This patch fixes both problems and
    makes the code simpler, too.

    A consequence of this patch is that the result array is now 0-based in
    all dimensions instead of starting at the numbering to match the first
    element of the source array.  The Fortran standard only specifies the
    shape of the result array, not its lower bounds, so this is permitted
    and probably less confusing for users as well as implementors.

    2021-07-17  Sandra Loosemore  <sandra@codesourcery.com>

            PR libfortran/101310

    libgfortran/
            * runtime/ISO_Fortran_binding.c (CFI_section): Fix the base
            address computation and simplify the code.

    gcc/testsuite/
            * gfortran.dg/ISO_Fortran_binding_1.c (section_c): Remove
            incorrect assertions.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug libfortran/101310] Bind(C): CFI_section seems confused by pointer arrays
  2021-07-03 20:48 [Bug libfortran/101310] New: Bind(C): CFI_section seems confused by pointer arrays sandra at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2021-07-28  4:25 ` cvs-commit at gcc dot gnu.org
@ 2021-07-28 20:22 ` sandra at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: sandra at gcc dot gnu.org @ 2021-07-28 20:22 UTC (permalink / raw)
  To: gcc-bugs

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

sandra at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |FIXED

--- Comment #4 from sandra at gcc dot gnu.org ---
Fixed on trunk.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-07-28 20:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-03 20:48 [Bug libfortran/101310] New: Bind(C): CFI_section seems confused by pointer arrays sandra at gcc dot gnu.org
2021-07-17 20:35 ` [Bug libfortran/101310] " sandra at gcc dot gnu.org
2021-07-18  5:54 ` sandra at gcc dot gnu.org
2021-07-28  4:25 ` cvs-commit at gcc dot gnu.org
2021-07-28 20:22 ` sandra at gcc dot gnu.org

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).