https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59161
--- Comment #8 from Pedro Alves <palves at redhat dot com> ---
Sounds like Paul's original patch may have introduced an undesired conflation.
AFAICS, options.addressprint's exists to implement "set print address on/off",
which had for original motivation, from the manual:
You can use @samp{set print address off} to eliminate all machine
dependent displays from the @value{GDBN} interface. For example, with
@code{print address off}, you should get the same text for backtraces on
all machines---whether or not they involve pointer arguments.
[1] https://sourceware.org/gdb/current/onlinedocs/gdb/Print-Settings.html
With that in mind, skipping the address on references seems to make as much
sense as skipping it on pointers.
Let's also take a look at what happens if you bypass the printer, with /r:
(gdb) set print address on
(gdb) p /r it
$2 = {_M_current = 0x614c20}
(gdb) p /r it._M_current
$3 = (C *) 0x614c20
(gdb) p /r *it._M_current
$4 = {ref = @0x7fffffffd908}
(gdb) p /r it._M_current.ref
$5 = (int &) @0x7fffffffd908: 1
(gdb) set print address off
(gdb) p /r it
$6 = {_M_current = }
(gdb) p /r it._M_current
$7 = (C *)
(gdb) p /r *it._M_current
$8 = {ref = }
(gdb) p /r it._M_current.ref
$9 = (int &) 1
Particularly, note how:
(gdb) p /r *it._M_current
$4 = {ref = @0x7fffffffd908}
doesn't print the value of the reference field, while if you print it directly,
it's printed:
(gdb) p /r it._M_current.ref
$5 = (int &) @0x7fffffffd908: 1
I wonder whether we should change gdb to print it, like:
(gdb) p /r *it._M_current
$1 = {ref = (int &) @0x7fffffffd908: 1}
and then with "print address off", you'd get:
(gdb) p /r *it._M_current
$1 = {ref = (int &) 1}
But that question should be answered independently from the pretty printer
question. I.e., what do people that debug C++ programs would find the most
useful default behavior to be, without pretty printers in the picture. (Not
enough C++ references in GDB's own codebase yet for me to have a clear opinion
yet. :-) )