From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28474 invoked by alias); 20 Sep 2011 16:12:28 -0000 Received: (qmail 28462 invoked by uid 22791); 20 Sep 2011 16:12:27 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mail-gx0-f169.google.com (HELO mail-gx0-f169.google.com) (209.85.161.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 20 Sep 2011 16:12:07 +0000 Received: by gxk2 with SMTP id 2so569422gxk.0 for ; Tue, 20 Sep 2011 09:12:06 -0700 (PDT) MIME-Version: 1.0 Received: by 10.236.145.10 with SMTP id o10mr6072629yhj.90.1316535126430; Tue, 20 Sep 2011 09:12:06 -0700 (PDT) Received: by 10.236.203.135 with HTTP; Tue, 20 Sep 2011 09:12:06 -0700 (PDT) In-Reply-To: <09787EF419216C41A903FD14EE5506DD03094C6D5D@AUSX7MCPC103.AMER.DELL.COM> References: <09787EF419216C41A903FD14EE5506DD03094C6D5D@AUSX7MCPC103.AMER.DELL.COM> Date: Tue, 20 Sep 2011 16:12:00 -0000 Message-ID: Subject: Re: Python: should gdb.Value array indexing check bounds? From: Matt Rice To: Paul_Koning@dell.com Cc: gdb@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2011-09/txt/msg00070.txt.bz2 On Tue, Sep 20, 2011 at 9:04 AM, wrote: > Currently, if a gdb.Value object corresponds to an array, array indexing = is done C-style: no bounds checking, just pointer arithmetic.=A0 That's som= ewhat unnatural to Python.=A0 Should it do a range check instead, and raise= IndexError for out of range index values? > > That wouldn't affect indexing of pointers, since those don't have a range= so the only possible approach is the C one. I'd think no because of things like: http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Zero-Length.html (which is possible with non-zero length arrays also).