From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30359 invoked by alias); 29 Mar 2002 23:27:00 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 30351 invoked from network); 29 Mar 2002 23:26:59 -0000 Received: from unknown (HELO mail-out2.apple.com) (17.254.0.51) by sources.redhat.com with SMTP; 29 Mar 2002 23:26:59 -0000 Received: from mailgate2.apple.com (A17-129-100-225.apple.com [17.129.100.225]) by mail-out2.apple.com (8.11.3/8.11.3) with ESMTP id g2TNQwa06117 for ; Fri, 29 Mar 2002 15:26:58 -0800 (PST) Received: from scv3.apple.com (scv3.apple.com) by mailgate2.apple.com (Content Technologies SMTPRS 4.2.1) with ESMTP id for ; Fri, 29 Mar 2002 15:26:58 -0800 Received: from inghji (inghji.apple.com [17.202.40.220]) by scv3.apple.com (8.11.3/8.11.3) with ESMTP id g2TNQwv01515 for ; Fri, 29 Mar 2002 15:26:58 -0800 (PST) Date: Fri, 29 Mar 2002 15:27:00 -0000 Mime-Version: 1.0 (Apple Message framework v481) Content-Type: text/plain; charset=US-ASCII; format=flowed Subject: Trivial fix in value_sub From: Jim Ingham To: gdb-patches@sources.redhat.com Content-Transfer-Encoding: 7bit Message-Id: <76AD507E-436C-11D6-890B-000393540DDC@apple.com> X-SW-Source: 2002-03/txt/msg00611.txt.bz2 In value_sub, if you are doing pointer - integer and pointer points to an incomplete type, then the computation: ptr - sizeof (*ptr) * integer turns into just: ptr which is probably not what the user expected. In value_add, the return from TYPE_LENGTH is checked for zero, and set to 1 if it is. We should probably do the same thing for value_sub, a la: 2002-03-29 James Ingham * valarith.c (value_sub): If you are doing pointer - integer, and TYPE_LENGTH of the pointer's target comes back 0, set it to 1. This is what value_add does, and we should be consistent. Index: valarith.c =================================================================== RCS file: /cvs/src/src/gdb/valarith.c,v retrieving revision 1.14 diff -c -w -r1.14 valarith.c *** valarith.c 2002/03/27 21:35:35 1.14 --- valarith.c 2002/03/29 23:22:27 *************** *** 105,110 **** --- 105,112 ---- { /* pointer - integer. */ LONGEST sz = TYPE_LENGTH (check_typedef (TYPE_TARGET_TYPE (type1))); + if (sz == 0) + sz = 1; return value_from_pointer (type1, (value_as_address (arg1) - (sz * value_as_long (arg2)))); Jim -- Jim Ingham jingham@apple.com Developer Tools - gdb Apple Computer