From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23500 invoked by alias); 31 Dec 2011 01:46:52 -0000 Received: (qmail 23490 invoked by uid 22791); 31 Dec 2011 01:46:51 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 31 Dec 2011 01:46:37 +0000 From: "vincent-gcc at vinc17 dot net" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/51721] New: -Warray-bounds false positives and inconsistencies Date: Sat, 31 Dec 2011 01:51:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: vincent-gcc at vinc17 dot net X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 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: 2011-12/txt/msg02866.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51721 Bug #: 51721 Summary: -Warray-bounds false positives and inconsistencies Classification: Unclassified Product: gcc Version: 4.6.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization AssignedTo: unassigned@gcc.gnu.org ReportedBy: vincent-gcc@vinc17.net I get strange -Warray-bounds false positives on the following code: static int a[10], b[10], c[10], d[10]; unsigned int f (unsigned int v) { return v == 17 ? 11 : v; } unsigned int g (unsigned int v) { return v == 17 ? 17 : v; } void t (unsigned int s) { if (s >> 1 == 0) { a[f(s)] = 0; a[f(s)] = 0; b[f(s)] = 0; c[g(s)] = 0; c[g(s)] = 0; d[H(s)] = 0; } } With gcc (Debian 4.6.2-9) 4.6.2 on a Debian/x86_64 machine: $ gcc-snapshot -O2 -Warray-bounds -c bounds.c -DH=f bounds.c: In function 't': bounds.c:17:8: warning: array subscript is above array bounds [-Warray-bounds] bounds.c:19:8: warning: array subscript is above array bounds [-Warray-bounds] bounds.c:20:8: warning: array subscript is above array bounds [-Warray-bounds] $ gcc-snapshot -O2 -Warray-bounds -c bounds.c -DH=g bounds.c: In function 't': bounds.c:17:8: warning: array subscript is above array bounds [-Warray-bounds] Note: line 17 is the first "a[f(s)] = 0;".