From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11446 invoked by alias); 18 Oct 2007 09:37:46 -0000 Received: (qmail 11435 invoked by uid 22791); 18 Oct 2007 09:37:45 -0000 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 18 Oct 2007 09:37:38 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id B19DA2ABAFE for ; Thu, 18 Oct 2007 05:37:36 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id gH-EbzNmJM1j for ; Thu, 18 Oct 2007 05:37:36 -0400 (EDT) Received: from nile.gnat.com (nile.gnat.com [205.232.38.5]) by rock.gnat.com (Postfix) with ESMTP id 8D0AC2ABAFD for ; Thu, 18 Oct 2007 05:37:36 -0400 (EDT) Received: by nile.gnat.com (Postfix, from userid 1345) id 8076A48CB9C; Thu, 18 Oct 2007 05:37:36 -0400 (EDT) From: Paul Hilfinger To: gdb@sourceware.org Subject: print/x on references Reply-to: Hilfinger@adacore.com Message-Id: <20071018093736.8076A48CB9C@nile.gnat.com> Date: Thu, 18 Oct 2007 09:37:00 -0000 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/msg00133.txt.bz2 Currently, there is a slight discrepancy in the behavior of formatted print commands. Stop the program below in f. At that point, we see the following behavior: (gdb) p x $4 = (Glorp &) @0x8049850: {x = 1, y = 2} (gdb) p/x x $5 = 0x8049850 Is there any particular reason these two cases shouldn't have the same behavior? It seems that printcmd.c:print_formatted is conflating the cases of C++ pointers and C++ references, and I don't see the justification for doing so. True, it's easy enough to kludge around: (gdb) p/x *&x But it is slightly annoying to have to do this. Admittedly, I'm speaking more from the Ada camp, where the equivalent kludge is more verbose (and from the user's point of view, less motivated). Still, would anyone object if this behavior were to change? P. Hilfinger ------------------------------------------------------------ #include using namespace std; struct Glorp { int x, y; }; Glorp z = { 1, 2 }; void f (Glorp& x) { cout << x.x << ", " << x.y << endl; } main () { f(z); }