From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31922 invoked by alias); 4 Apr 2008 09:42:11 -0000 Received: (qmail 31913 invoked by uid 22791); 4 Apr 2008 09:42:11 -0000 X-Spam-Check-By: sourceware.org Received: from wf-out-1314.google.com (HELO wf-out-1314.google.com) (209.85.200.170) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 04 Apr 2008 09:41:54 +0000 Received: by wf-out-1314.google.com with SMTP id 28so3782465wfc.14 for ; Fri, 04 Apr 2008 02:41:52 -0700 (PDT) Received: by 10.142.84.3 with SMTP id h3mr712835wfb.34.1207302112082; Fri, 04 Apr 2008 02:41:52 -0700 (PDT) Received: by 10.142.100.19 with HTTP; Fri, 4 Apr 2008 02:41:52 -0700 (PDT) Message-ID: <84fc9c000804040241l98b2f6esd052290fa66b4303@mail.gmail.com> Date: Fri, 04 Apr 2008 09:59:00 -0000 From: "Richard Guenther" To: "Simon Baldwin" Subject: Re: [PATCH][RFC] Add a subset of -Warray-bounds warnings to C/C++ front ends Cc: gcc-patches@gcc.gnu.org In-Reply-To: <20080404000715.3C75741AB58@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <20080404000715.3C75741AB58@localhost> X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2008-04/txt/msg00359.txt.bz2 On Fri, Apr 4, 2008 at 1:07 AM, Simon Baldwin wrote: > Attached below is a modest patch to provide a subset of the -Warray-bounds > warnings from tree-vrp.c in the C and C++ front ends. This permits the > compiler to warn about egregious array bounds violations in unoptimized > compilations or compilations that may use -fno-tree-vrp. At present, array > bounds checking is only done on optimized compilations. > > A side effect of copying these warnings up into the language frontends is > that warnings are now printed even if the array access is in dead or > inaccessible code. > > The current array bounds tests are modified to account for this new checking, > and additionally there are two new tests for warnings from -O0 compilations, > one for C and one for C++. > > Bootstrapped, and regression tested on i686 Linux for gcc and g++. > > Thoughts? Okay for trunk? I think it is a good thing to move these to the frontends. Did you test the warning on some real-world C and C++ code? I expect some "false" positives from deliberately partial dead code coming from template instantiation or constant propagation from function arguments. Thanks, Richard.