Re: print/x on references

Jim Blandy
2007-10-19T21:40:38Z

Daniel Jacobowitz <drow at false.org> writes:
> On Thu, Oct 18, 2007 at 10:45:14AM -0700, Douglas Evans wrote:
>> fwiw,
>> I think the expression evaluator should work as the language does (as
>> much as possible). And once it does that then thought is given to
>> whatever extensions are needed to accomplish things not possible with
>> the language syntax.
>> e.g. "p cut-n-pasted-expression-from-source" should "just work" (to
>> some reasonable extent).
>>
>> Given that, to me "p &cref" -> (c*) and not (c**) follows naturally
>> out of c++ syntax. Whatever goop we want to add to get at the address
>> of the object containing the reference is separate. "p &(&cref)" is
>> the first thing that came to mind and wonderfully it "just worked".
>> One may want a different (or additional) way to achieve this of
>> course, but it should not break "p &cref" -> (c*).
>
> That is an excellent explanation. You've convinced me.

It turns out this is actually documented in the manual:

File: gdb.info, Node: C Operators

...

`&'
Address operator. Defined on variables. Same precedence as `++'.

For debugging C++, GDB implements a use of `&' beyond what is
allowed in the C++ language itself: you can use `&(&REF)' (or, if
you prefer, simply `&&REF') to examine the address where a C++
reference variable (declared with `&REF') is stored.