From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8410 invoked by alias); 5 Oct 2011 18:08:43 -0000 Received: (qmail 8398 invoked by uid 22791); 5 Oct 2011 18:08:42 -0000 X-SWARE-Spam-Status: No, hits=-7.2 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 05 Oct 2011 18:08:24 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p95I8Leg026454 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 5 Oct 2011 14:08:21 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p95I8LWv008696; Wed, 5 Oct 2011 14:08:21 -0400 Received: from barimba (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id p95I8JXE008111; Wed, 5 Oct 2011 14:08:20 -0400 From: Tom Tromey To: Paul Koning Cc: ratmice@gmail.com, gdb@sourceware.org Subject: Re: Python: should gdb.Value array indexing check bounds? References: <09787EF419216C41A903FD14EE5506DD03094C6D5D@AUSX7MCPC103.AMER.DELL.COM> <09787EF419216C41A903FD14EE5506DD03094C6D7D@AUSX7MCPC103.AMER.DELL.COM> <7A2DB38D-692D-4E15-BBCE-EFFD115F47DA@comcast.net> Date: Wed, 05 Oct 2011 18:08:00 -0000 In-Reply-To: <7A2DB38D-692D-4E15-BBCE-EFFD115F47DA@comcast.net> (Paul Koning's message of "Tue, 20 Sep 2011 12:18:30 -0400") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain 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-10/txt/msg00014.txt.bz2 >>>>> "Paul" == Paul Koning writes: Paul> Currently, if a gdb.Value object corresponds to an array, array Paul> indexing is done C-style: no bounds checking, just pointer Paul> arithmetic. That's somewhat unnatural to Python. Should it do a Paul> range check instead, and raise IndexError for out of range index Paul> values? I think it would be good if the bad cases could somehow be avoided. Matt> I'd think no because of things like: Matt> http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Zero-Length.html Matt> (which is possible with non-zero length arrays also). Paul> I suppose that could be handled by making the check not apply in that Paul> case. I think there are other bad cases -- e.g., the classic C struct hack uses an array with 1 element. Paul> Or the bounds could be made writable? Right now the bounds go Paul> with the type, not the value; for them to be writable they would have Paul> to go with the value. This sounds like Jan's VLA patchset. I'm not sure how rewriting the bounds would work in practice. I guess you could just cast the array to a pointer today. Tom