summaryrefslogtreecommitdiff
path: root/gdb/valarith.c
diff options
context:
space:
mode:
authorcmoller <cmoller>2010-02-08 18:27:53 +0000
committercmoller <cmoller>2010-02-08 18:27:53 +0000
commit3a1fc260f01d38b733dc4e7941cb3172dfdf6d01 (patch)
treea94dc82d0c59f5d5902aaa1bca380e8191fff3bd /gdb/valarith.c
parent93a1fa4f1853fca63cb20e433d7c5df83fa140d8 (diff)
downloadgdb-3a1fc260f01d38b733dc4e7941cb3172dfdf6d01.tar.gz
PR gdb/10728
* valarith.c (value_ptrdiff): Added a test for a zero type length, warn if found, and assume length = 1. * gdb.cp/pr10728-x.h: New file. * gdb.cp/pr10728-x.cc: New file. * gdb.cp/pr10728-y.cc: New file. * gdb.cp/pr10728.exp: New file. * gdb.cp/Makefile.in (EXECUTABLES): Add pr10728
Diffstat (limited to 'gdb/valarith.c')
-rw-r--r--gdb/valarith.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/gdb/valarith.c b/gdb/valarith.c
index ed76b0960ba..c87bc6f255e 100644
--- a/gdb/valarith.c
+++ b/gdb/valarith.c
@@ -122,6 +122,13 @@ First argument of `-' is a pointer and second argument is neither\n\
an integer nor a pointer of the same type."));
sz = TYPE_LENGTH (check_typedef (TYPE_TARGET_TYPE (type1)));
+ if (sz == 0)
+ {
+ warning (_("Type size unknown, assuming 1. "
+ "Try casting to a known type, or void *."));
+ sz = 1;
+ }
+
return (value_as_long (arg1) - value_as_long (arg2)) / sz;
}