This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: Trivial bug in valarith.c
- To: Jim blandy <jimb at cygnus dot com>
- Subject: Re: Trivial bug in valarith.c
- From: Andrew Cagney <ac131313 at cygnus dot com>
- Date: Sat, 13 Oct 2001 19:21:24 -0400
- Cc: Jim Ingham <jingham at apple dot com>, gdb-patches at sources dot redhat dot com
- References: <A470273E-BF99-11D5-AA27-000A277A8808@apple.com>
JimB,
While this looks, er obvious, can you give it a quick peek (I think you
last touched that code ;-). Looks like this problem is also on the 5.1
branch :-/
JimI,
Do you have the ChangeLog entry? Any chance of a testcase? BTW, I guess:
(gdb) x/b myPtr+1
also causes the crash - that is slightly more valid.
enjoy,
Andrew
> Hi, all...
>
> There's a trivial bug in valarith.c, in value_sub. Here is the patch:
>
> Index: valarith.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/valarith.c,v
> retrieving revision 1.9
> diff -c -w -r1.9 valarith.c
> *** valarith.c 2001/09/24 17:16:53 1.9
> --- valarith.c 2001/10/13 05:03:06
> ***************
> *** 104,110 ****
> {
> /* pointer - integer. */
> LONGEST sz = TYPE_LENGTH (check_typedef (TYPE_TARGET_TYPE (type1)));
> ! return value_from_pointer (VALUE_TYPE (arg1),
> (value_as_pointer (arg1)
> - (sz * value_as_long (arg2))));
> }
> --- 104,110 ----
> {
> /* pointer - integer. */
> LONGEST sz = TYPE_LENGTH (check_typedef (TYPE_TARGET_TYPE (type1)));
> ! return value_from_pointer (type1,
> (value_as_pointer (arg1)
> - (sz * value_as_long (arg2))));
> }