From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2A53B385801D; Wed, 28 Oct 2020 20:27:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2A53B385801D From: "anlauf at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/30802] out of bounds error array I/O not picked up with -fbounds-check Date: Wed, 28 Oct 2020 20:27:05 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 4.1.1 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: anlauf at gcc dot gnu.org X-Bugzilla-Status: NEW 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: cc see_also Message-ID: In-Reply-To: References: 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: Wed, 28 Oct 2020 20:27:06 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D30802 anlauf at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |anlauf at gcc dot gnu.org See Also| |https://gcc.gnu.org/bugzill | |a/show_bug.cgi?id=3D97039 --- Comment #9 from anlauf at gcc dot gnu.org --- (In reply to markeggleston from comment #8) > Changing to allocated arrays and bounds checking does not work at compile > time but does at runtime: >=20 > program test > real, allocatable :: x(:) > allocate(x(10)) > x =3D 0.0 > print *, x(0) > deallocate(x) > end program test >=20 > $ gfortran -fbounds-check pr30802.f90 > $ ./a.out >=20 > At line 5 of file pr30802.f90 > Fortran runtime error: Index '0' of dimension 1 of array 'x' below lower > bound of 1 >=20 > Error termination. Backtrace: > #0 0x400ea1 in ??? > #1 0x400f6d in ??? > #2 0x4380b2 in ??? > #3 0x438471 in ??? > #4 0x400c69 in ??? I think the point is that bounds-checking does not work for sections of ran= k-2 arrays. See also PR97039. This is not I/O specific, but what Thomas said in comment#3.=