This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: print/x on references
On 10/18/07, Daniel Jacobowitz <drow@false.org> wrote:
> On Thu, Oct 18, 2007 at 10:03:01AM -0700, Douglas Evans wrote:
> > To find the address of the pointer to the object I was thinking "p
> > &(&x)". It works, at least in the simple example I used to experiment
> > with.
>
> That is such a horrible abuse of C++ that I didn't even think to try
> it. Egads. Not quite sure how I feel about that!
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*).
fwiw of course.