From patchwork Tue Jan 6 15:16:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Brobecker X-Patchwork-Id: 4525 Received: (qmail 9643 invoked by alias); 6 Jan 2015 15:16:47 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 9627 invoked by uid 89); 6 Jan 2015 15:16:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL, BAYES_00, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Tue, 06 Jan 2015 15:16:45 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 7BF52116474 for ; Tue, 6 Jan 2015 10:16:43 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 6vNZH-0hoSZO for ; Tue, 6 Jan 2015 10:16:43 -0500 (EST) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 3669111647B for ; Tue, 6 Jan 2015 10:16:41 -0500 (EST) Received: by joel.gnat.com (Postfix, from userid 1000) id EB9F04100E; Tue, 6 Jan 2015 19:16:36 +0400 (RET) From: Joel Brobecker To: gdb-patches@sourceware.org Subject: [pushed/ob] gdb/guile: Do not error when trying to create empty array. Date: Tue, 6 Jan 2015 19:16:32 +0400 Message-Id: <1420557392-14713-1-git-send-email-brobecker@adacore.com> This fixes a similar error as in the Python support code where trying to create an empty array. In guile/scm-type.c::tyscm_array_1, the funtion raises an exception if N2 < N1: if (n2 < n1) { gdbscm_out_of_range_error (func_name, SCM_ARG3, But it should be doing so if N2 == N1 - 1, since that would simply be an empty array, not an array with a negative length. gdb/ChangeLog: * guile/scm-type.c (tyscm_array_1): Do not raise out-of-range error if N2 is equal to N1 - 1. No testcase, since I am not setup to build with Guile. Should be trivial for anyone interested in adding one (see the tests I added in gdb.python/py-type.exp as an example of what I added). Pushed as obvious. Thanks, diff --git a/gdb/ChangeLog b/gdb/ChangeLog index a6211bf..8e3737d 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,10 @@ 2015-01-06 Joel Brobecker + * guile/scm-type.c (tyscm_array_1): Do not raise out-of-range + error if N2 is equal to N1 - 1. + +2015-01-06 Joel Brobecker + * python/py-type.c (typy_array_1): Do not raise negative-length exception if N2 is equal to N1 - 1. diff --git a/gdb/guile/scm-type.c b/gdb/guile/scm-type.c index 92d5328..4f46139 100644 --- a/gdb/guile/scm-type.c +++ b/gdb/guile/scm-type.c @@ -713,7 +713,7 @@ tyscm_array_1 (SCM self, SCM n1_scm, SCM n2_scm, int is_vector, n1 = 0; } - if (n2 < n1) + if (n2 < n1 - 1) { gdbscm_out_of_range_error (func_name, SCM_ARG3, scm_cons (scm_from_long (n1),