Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jim Ingham <jingham@apple.com>
To: gdb-patches@sources.redhat.com
Subject: Trivial fix in value_sub
Date: Fri, 29 Mar 2002 15:27:00 -0000	[thread overview]
Message-ID: <76AD507E-436C-11D6-890B-000393540DDC@apple.com> (raw)

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  <jingham@apple.com>

         * 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


             reply	other threads:[~2002-03-29 23:27 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-03-29 15:27 Jim Ingham [this message]
2002-04-03 14:52 ` Jim Blandy
2002-04-03 15:55   ` Michael Snyder
2002-04-03 16:11   ` Jim Ingham
2002-04-03 19:55     ` Jim Blandy
2002-04-03 20:11       ` Daniel Jacobowitz
2002-04-04 13:46         ` Jim Ingham
2002-04-04 14:24           ` Jim Blandy
2002-04-04 15:07             ` Jim Ingham
2002-04-04 15:15               ` Jim Blandy
2002-04-09 17:12                 ` Jim Ingham

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=76AD507E-436C-11D6-890B-000393540DDC@apple.com \
    --to=jingham@apple.com \
    --cc=gdb-patches@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox