diff options
author | Chris Moller <cmoller@cygnus> | 2010-02-08 18:27:53 +0000 |
---|---|---|
committer | Chris Moller <cmoller@cygnus> | 2010-02-08 18:27:53 +0000 |
commit | 83b10087f47feb355bbdc02f8fcd336c0bf000aa (patch) | |
tree | 71a06b00238d30b35d0aecea6c52f633a667f664 /gdb/valarith.c | |
parent | 99903ae39ebb2032c28aa7bb8b24d6d0f901a2f1 (diff) | |
download | binutils-gdb-83b10087f47feb355bbdc02f8fcd336c0bf000aa.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.c | 7 |
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; } |