From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17276 invoked by alias); 19 Oct 2007 21:40:38 -0000 Received: (qmail 17265 invoked by uid 22791); 19 Oct 2007 21:40:37 -0000 X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 19 Oct 2007 21:40:34 +0000 Received: (qmail 10877 invoked from network); 19 Oct 2007 21:40:33 -0000 Received: from unknown (HELO localhost) (jimb@127.0.0.2) by mail.codesourcery.com with ESMTPA; 19 Oct 2007 21:40:33 -0000 To: Douglas Evans Cc: Paul Hilfinger , gdb@sourceware.org Subject: Re: print/x on references References: <20071018093736.8076A48CB9C@nile.gnat.com> <20071018111644.GA32574@caradoc.them.org> <20071018163012.GA19490@caradoc.them.org> <20071018171114.GA21738@caradoc.them.org> <20071018192103.GA31401@caradoc.them.org> From: Jim Blandy Date: Fri, 19 Oct 2007 21:40:00 -0000 In-Reply-To: <20071018192103.GA31401@caradoc.them.org> (Daniel Jacobowitz's message of "Thu, 18 Oct 2007 15:21:03 -0400") Message-ID: User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2007-10/txt/msg00179.txt.bz2 Daniel Jacobowitz 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.