From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30609 invoked by alias); 17 Oct 2002 21:26:01 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 30589 invoked by uid 71); 17 Oct 2002 21:26:00 -0000 Resent-Date: 17 Oct 2002 21:26:00 -0000 Resent-Message-ID: <20021017212600.30588.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, d.binderman@virgin.net Received: (qmail 28260 invoked by uid 61); 17 Oct 2002 21:20:11 -0000 Message-Id: <20021017212011.28259.qmail@sources.redhat.com> Date: Thu, 17 Oct 2002 14:26:00 -0000 From: d.binderman@virgin.net Reply-To: d.binderman@virgin.net To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: c/8268: no compile time array index checking X-SW-Source: 2002-10/txt/msg00695.txt.bz2 List-Id: >Number: 8268 >Category: c >Synopsis: no compile time array index checking >Confidential: no >Severity: non-critical >Priority: low >Responsible: unassigned >State: open >Class: accepts-illegal >Submitter-Id: net >Arrival-Date: Thu Oct 17 14:26:00 PDT 2002 >Closed-Date: >Last-Modified: >Originator: d.binderman@virgin.net >Release: gcc 3.2 >Organization: >Environment: >Description: # include // some compilers can find fault with this // simple case int a[ 10]; void f() { a[ -1] = -1; // bug a[ 0] = 0; a[ 9] = 9; a[ 10] = 10; // bug } // bit more complex void g() { int b[ 10]; const int n = 5; b[ 2 * n - 11] = -1; // bug b[ 2 * n - 10] = 0; b[ n + 4] = 9; b[ n + 5] = 10; // bug } // Can any compiler find fault with this ? void h() { int * const c = (int *) malloc( 10 * sizeof( int)); int n = 5; c[ 2 * n - 11] = -1; // bug c[ 2 * n - 10] = 0; c[ n + 4] = 9; c[ n + 5] = 10; // bug free( c); } >How-To-Repeat: I tried to compile the above source code with gcc 3.2 -g -O2 -Wall. It produced no warnings. I count six bugs in the code. >Fix: >Release-Note: >Audit-Trail: >Unformatted: