From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26356 invoked by alias); 5 Aug 2010 12:21:45 -0000 Received: (qmail 26270 invoked by uid 48); 5 Aug 2010 12:21:26 -0000 Date: Thu, 05 Aug 2010 12:21:00 -0000 Subject: [Bug tree-optimization/45195] New: incorrect "array subscript above bounds" warning X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "rahul at icerasemi 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-08/txt/msg00306.txt.bz2 Using GCC 4.4.1 and the following command, test generates an "array subscript is above array bounds" warning. gcc -S -Os test.c -Wall void foo (int b[2][6]) { int i = 0; for (i = 0; i < 6; i++) { int *pb = &b[1][i]; *pb = 0; } } Output from VRP looks like foo (int[6] * b) { int i; unsigned int D.1240; unsigned int i.0; : goto ; : # i_16 = PHI i.0_6 = (unsigned int) i_16; D.1240_7 = i.0_6 + 6; (*b_4(D))[D.1240_7] = 0; <-- warning generated here i_10 = i_16 + 1; : # i_1 = PHI if (i_1 <= 5) goto ; else goto ; : return; : # i_14 = PHI <0(2)> goto ; } In the statement (*b_4(D))[D.1240_7] = 0, range of b_4 appears to be [0 5] while the range of index D.1240_7 is [6 11]. -- Summary: incorrect "array subscript above bounds" warning Product: gcc Version: 4.4.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: rahul at icerasemi dot com GCC build triplet: i686-pc-linux GCC host triplet: i686-pc-linux GCC target triplet: i686-pc-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45195