public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* print/x on references
@ 2007-10-18  9:37 Paul Hilfinger
  2007-10-18 11:16 ` Daniel Jacobowitz
  0 siblings, 1 reply; 14+ messages in thread
From: Paul Hilfinger @ 2007-10-18  9:37 UTC (permalink / raw)
  To: gdb


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 <iostream>

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);
}

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2007-10-19 22:00 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-18  9:37 print/x on references Paul Hilfinger
2007-10-18 11:16 ` Daniel Jacobowitz
2007-10-18 16:05   ` Douglas Evans
2007-10-18 16:30     ` Daniel Jacobowitz
2007-10-18 17:03       ` Douglas Evans
2007-10-18 17:10         ` Douglas Evans
2007-10-18 17:11         ` Daniel Jacobowitz
2007-10-18 17:45           ` Douglas Evans
2007-10-18 19:10             ` Paul Hilfinger
2007-10-18 19:21             ` Daniel Jacobowitz
2007-10-18 19:30               ` Paul Hilfinger
2007-10-18 19:39                 ` Daniel Jacobowitz
2007-10-19 21:40               ` Jim Blandy
2007-10-19 22:00                 ` Daniel Jacobowitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).