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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |burnus at gcc dot gnu.org
         Depends on|                            |92189
         Resolution|---                         |INVALID

--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> ---
> The problems reported vary depending on the array having the allocatable or
> pointer attributes.

In any case, your example is INVALID:

Fortran 2018 has in "15.5.2.13  Restrictions on entities associated with dummy
arguments":
"While an entity is associated with a dummy argument, the following
restrictions hold.
(1) Action that affects the allocation status of the entity or a subobject
thereof shall be taken through the dummy argument.
[…]"

Any your code does:
  call arr_set(arr)
…
   subroutine arr_set(this) bind(c)
    integer(kind=c_int), pointer, intent(out) :: this(:)
    allocate(arr(n))
…
    do i = 1, size(this)


If you fix your code, you might well run into my PR 92189.

[There are good reasons why it cannot work with 'pointer' even without bind(C).
For allocatable, without 'target' you also break the alias handling. And as
soon as the internal representation (array descriptor) w/ and w/o bind(C) is
different [as with gfortran] it can also not work – even with 'allocatable,
target'.]

 * * *

An ICE is still a bug, but as it is not a regression and does not fail with GCC
10, I still close this PR.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92189
[Bug 92189] Fortran-written bind(C) function with allocatable argument does not
update C descriptor on exit

Reply via email to