From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28467 invoked by alias); 27 May 2010 20:31:37 -0000 Received: (qmail 28411 invoked by uid 48); 27 May 2010 20:31:24 -0000 Date: Thu, 27 May 2010 20:31:00 -0000 Message-ID: <20100527203124.28410.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug c/44300] Spurious array subscript warning In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "jmattson at vmware dot com" 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 X-SW-Source: 2010-05/txt/msg03065.txt.bz2 ------- Comment #3 from jmattson at vmware dot com 2010-05-27 20:31 ------- Admittedly, foo() makes some assumptions about alignment as originally written. A more pedantic version is: static inline void foo(int *p) { if (p >= a + 1 && p < a + 10) { p[-1] = 0; } } gcc still generates a warning with this version. Even if a[] and b[] overlap, the guard clause ensures that the expression 'p[-1]' is within the bounds of array a[]. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44300