diff options
author | Pedro Alves <palves@redhat.com> | 2013-02-14 12:43:46 +0000 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2013-02-14 12:43:46 +0000 |
commit | 4819b3f897686ee8a2d51f6ba1c9c4e7c3a22597 (patch) | |
tree | a22f2b46ad84bf216d9f556011991e983b6cfb82 /gdb/ChangeLog | |
parent | d99b05a32ecaecbaaac6c07f9cbcd8ba46746951 (diff) | |
download | gdb-4819b3f897686ee8a2d51f6ba1c9c4e7c3a22597.zip gdb-4819b3f897686ee8a2d51f6ba1c9c4e7c3a22597.tar.gz gdb-4819b3f897686ee8a2d51f6ba1c9c4e7c3a22597.tar.bz2 |
Fix ptype bug actually exercised in userdef.exp
I happened to notice a bug with ptype &Ref, and found out userdef.exp
actually exercises the bug. With:
class Container
{
public:
Member m;
Member& operator* ();
};
Member& Container::operator* ()
{
return this->m;
}
And 'c' is of type Container:
(gdb) p c
$1 = {m = {z = -9192}}
(gdb) p *c
$2 = (Member &) @0x7fffffffda20: {z = -9192}
(gdb) ptype *c
type = class Member {
public:
int z;
} &
(gdb) p &*c
$3 = (Member *) 0x7fffffffda20
(gdb) ptype &*c
type = class Member {
public:
int z;
} &*
(gdb)
Notice that last print (&*c) on says the type is a pointer - that's
how you get the address behind a reference. But notice the last ptype
instead says the type of the same expression is a pointer _reference_.
This looks like a bug to me.
This patch fixes it. The issue is that we're entering the VALUE_LVAL
(x) == lval_memory branch by mistake for references. The fix is just
to swap the tests so references are checked first, like value_addr
also handles references first.
Tested on x86_64 Fedora 17.
2013-02-14 Pedro Alves <palves@redhat.com>
* eval.c (evaluate_subexp_for_address) <default_case_after_eval,
EVAL_AVOID_SIDE_EFFECTS>: Swap and handle TYPE_CODE_REF before
lval_memory.
2013-02-14 Pedro Alves <palves@redhat.com>
* gdb.cp/userdef.exp (ptype &*c): Don't expect an &.
Diffstat (limited to 'gdb/ChangeLog')
-rw-r--r-- | gdb/ChangeLog | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index ae09cc1..0a3f85d 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2013-02-14 Pedro Alves <palves@redhat.com> + + * eval.c (evaluate_subexp_for_address) <default_case_after_eval, + EVAL_AVOID_SIDE_EFFECTS>: Swap and handle TYPE_CODE_REF before + lval_memory. + 2013-02-14 Pedro Alves <pedro@codesourcery.com> Hafiz Abid Qadeer <abidh@codesourcery.com> |