From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 704E33858D20; Fri, 4 Feb 2022 20:45:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 704E33858D20 From: "michael at scivision dot dev" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/104391] New: Gfortran 9 regression with bind(C) and allocatable or pointer attribute Date: Fri, 04 Feb 2022 20:45:31 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 9.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: michael at scivision dot dev X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Feb 2022 20:45:31 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104391 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 exiti= ng a procedure with `bind(c)`, the variable(s) have their indices shifted to zero-based. example that works with GCC <=3D 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 =3D lbound(a,1) U1 =3D ubound(a,1) call c_bounder(a) L2 =3D lbound(a,1) U2 =3D ubound(a,1) if (L1 /=3D L2 .or. U1 /=3D 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 ```=