public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/104391] New: Gfortran 9 regression with bind(C) and allocatable or pointer attribute
@ 2022-02-04 20:45 michael at scivision dot dev
  2022-02-04 21:34 ` [Bug fortran/104391] [9/10/11 Regression] bind(C) and allocatable or pointer attribute don't work pinskia at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: michael at scivision dot dev @ 2022-02-04 20:45 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 104391
           Summary: Gfortran 9 regression with bind(C) and allocatable or
                    pointer attribute
           Product: gcc
           Version: 9.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: michael at scivision dot dev
  Target Milestone: ---

The `bind(C)` on a procedure appears to break `pointer` and `allocatable`
attributes of a variable with regard to index start. Specifically, on exiting a
procedure with `bind(c)`, the variable(s) have their indices shifted to
zero-based.

example that works with GCC <= 8.5 and GCC 12 (broken for GCC 9, 10, 11).

```
program test_bounds
use iso_fortran_env, only : error_unit
implicit none

real, allocatable :: a(:)
integer :: L1,L2, U1,U2
allocate(a(1:2))

L1 = lbound(a,1)
U1 = ubound(a,1)
call c_bounder(a)
L2 = lbound(a,1)
U2 = ubound(a,1)

if (L1 /= L2 .or. U1 /= U2) then
  write(error_unit, '(a,2i2,a,2i2)') 'FAIL: bounds changed before/after
lower:', L1,L2, " upper: ", U1,U2
  error stop
endif

print '(a)', "bounds check OK"

contains

subroutine c_bounder(a) bind(c)
real,  intent(inout) :: a(:)
end subroutine c_bounder

end program
```

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

end of thread, other threads:[~2024-04-25  6:20 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-04 20:45 [Bug fortran/104391] New: Gfortran 9 regression with bind(C) and allocatable or pointer attribute michael at scivision dot dev
2022-02-04 21:34 ` [Bug fortran/104391] [9/10/11 Regression] bind(C) and allocatable or pointer attribute don't work pinskia at gcc dot gnu.org
2022-02-05  3:14 ` pinskia at gcc dot gnu.org
2022-02-07  7:47 ` rguenth at gcc dot gnu.org
2022-02-22 10:51 ` marxin at gcc dot gnu.org
2022-05-27  9:47 ` [Bug fortran/104391] [10/11 " rguenth at gcc dot gnu.org
2022-06-28 10:48 ` jakub at gcc dot gnu.org
2023-07-07 10:42 ` [Bug fortran/104391] [11 " rguenth at gcc dot gnu.org
2024-04-25  6:20 ` pault 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).