From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10670 invoked by alias); 30 Dec 2011 00:38:58 -0000 Received: (qmail 10662 invoked by uid 22791); 30 Dec 2011 00:38:57 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from jlefevre.net1.nerim.net (HELO smtp-xvii.vinc17.net) (80.65.226.245) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 30 Dec 2011 00:38:23 +0000 Received: by xvii.vinc17.org (Postfix, from userid 1000) id C298A310080; Fri, 30 Dec 2011 01:38:21 +0100 (CET) Date: Fri, 30 Dec 2011 05:00:00 -0000 From: Vincent Lefevre To: gcc-help@gcc.gnu.org Subject: Re: False positive from -Warray-bounds? Message-ID: <20111230003821.GW5641@xvii.vinc17.org> Mail-Followup-To: gcc-help@gcc.gnu.org References: <20111229235727.GU5641@xvii.vinc17.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Mailer-Info: http://www.vinc17.net/mutt/ User-Agent: Mutt/1.5.21-6201-vl-r48020 (2011-12-20) X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2011-12/txt/msg00273.txt.bz2 On 2011-12-29 16:20:48 -0800, Ian Lance Taylor wrote: > To me this only proves that the compiler is not smart enough to see that > (s >> 1 == 0) implies that ((s & 0xffff) == 0xffff) can not be true. > > Are you suggesting that the compiler should never warn if there is a > conditional guarding the array access? Would that in practice be better > or worse than the current behaviour? I think there should be two different options: * one that would trigger the warning if the compiler can prove that there will always be an out-of-bound access when the function is executed (unless the compiler can prove that the function will never be executed); * one that would trigger the warning if there may be an out-of-bound access. BTW, can the user inform the compiler that some condition holds? i.e. some kind of assert() but specifically for the compiler. -- Vincent Lefèvre - Web: 100% accessible validated (X)HTML - Blog: Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon)