From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18955 invoked by alias); 28 May 2010 17:52:07 -0000 Received: (qmail 18893 invoked by uid 48); 28 May 2010 17:51:53 -0000 Date: Fri, 28 May 2010 17:52:00 -0000 Message-ID: <20100528175153.18892.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug middle-end/44300] Spurious array subscript warning, &b[0] == &a[1] is not folded In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "rguenth at gcc dot gnu dot org" 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/msg03172.txt.bz2 ------- Comment #10 from rguenth at gcc dot gnu dot org 2010-05-28 17:51 ------- (In reply to comment #9) > Okay. What if we stick with equality operators, then? > > static inline void > foo(int *p) > { > if (p == a + 1 || p == a + 2) { > p[-1] = 0; > } > } > > This code results in the same warning. Yep. That's because a and b might not bind locally and thus we do not know whether &b[0] == &a[1]. We don't warn for -fno-common, but in this case we might still optimize the comparison. Confirmed for the testcase in comment #9. -- rguenth at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |rguenth at gcc dot gnu dot | |org Status|UNCONFIRMED |NEW Component|c |middle-end Ever Confirmed|0 |1 Last reconfirmed|0000-00-00 00:00:00 |2010-05-28 17:51:52 date| | Summary|Spurious array subscript |Spurious array subscript |warning |warning, &b[0] == &a[1] is | |not folded http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44300