From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 872 invoked by alias); 29 Jan 2015 20:17:07 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 650 invoked by uid 48); 29 Jan 2015 20:16:58 -0000 From: "anlauf at gmx dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/64854] No bound check for explicit-shape arrays Date: Thu, 29 Jan 2015 20:17:00 -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.9.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: anlauf at gmx dot de X-Bugzilla-Status: WAITING 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 Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-01/txt/msg03443.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64854 Harald Anlauf changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |anlauf at gmx dot de --- Comment #3 from Harald Anlauf --- (In reply to Dominique d'Humieres from comment #1) > Well, you give wrong information to the compiler. How do expect it to handle > your mistake: in testsub -fcheck=bounds checks that n1<=i<=n2 which is the > case. What you ask for is a check that a(n1:n2) is inside a(1:10), AFAIK > such check is not implemented and I don't have any idea about how difficult > it is to implement it. valgrind detects this issue. I was expected that the address sanitizer is able to handle it, but I am getting linking errors on my system. > I am inclined to close tis PR as INVALID or WONTFIX. The right way to fix the problem is to fix the program by using an appropriate programming style. Writing real :: a(n1:) ! not: real :: a(n1:n2) one gets the expected check: At line 22 of file pr64854.f90 Fortran runtime error: Index '1048586' of dimension 1 of array 'a' above upper bound of 1048585 Backtrace for this error: + function testsub.3321 (0x80486A4) from file pr64854.f90 + in the main program from file pr64854.f90 + /lib/libc.so.6(__libc_start_main+0xf3) [0xb7424003] I also suggest to close the PR.