public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/25957] New: Unable to call std::map::operator[] from gdb
@ 2020-05-09 11:32 jengelh at inai dot de
2020-05-12 13:07 ` [Bug c++/25957] " ssbssa at sourceware dot org
0 siblings, 1 reply; 2+ messages in thread
From: jengelh at inai dot de @ 2020-05-09 11:32 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=25957
Bug ID: 25957
Summary: Unable to call std::map::operator[] from gdb
Product: gdb
Version: 8.3.1
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
Assignee: unassigned at sourceware dot org
Reporter: jengelh at inai dot de
Target Milestone: ---
# 7-liner test program
» g++ x.cpp -v -ggdb3 -O0 -fno-inline
gcc version 9.3.1 20200406 [revision 6db837a5288ee3ca5ec504fbd5a765817e556ac2]
(SUSE Linux)
...
» gdb a.out
GNU gdb (GDB; openSUSE Tumbleweed) 8.3.1
(gdb) b main
Breakpoint 1 at 0x11dd: file x.cpp, line 5.
(gdb) r
Starting program: /dev/shm/a.out
Breakpoint 1, main () at x.cpp:5
5 z[99] = 42;
(gdb) l
1 #include <map>
2 std::map<int, int> z;
3 int main()
4 {
5 z[99] = 42;
6 return 0;
7 }
(gdb) p z[99]
Attempt to take address of value not located in memory.
(gdb) p z.operator[](99)
Attempt to take address of value not located in memory.
Which value is not in memory? And why is it not in memory? What more does one
need beside -O0 -ggdb3?
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c++/25957] Unable to call std::map::operator[] from gdb
2020-05-09 11:32 [Bug c++/25957] New: Unable to call std::map::operator[] from gdb jengelh at inai dot de
@ 2020-05-12 13:07 ` ssbssa at sourceware dot org
0 siblings, 0 replies; 2+ messages in thread
From: ssbssa at sourceware dot org @ 2020-05-12 13:07 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=25957
Hannes Domani <ssbssa at sourceware dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ssbssa at sourceware dot org
--- Comment #1 from Hannes Domani <ssbssa at sourceware dot org> ---
The argument of operator[] is a reference:
_Key & operator[](const _Key &);
A simpler example is:
int const_ref_arg(const int &x)
{
return x;
}
int ref_arg(int &x)
{
return x;
}
int y;
int main()
{
return const_ref_arg(y) + ref_arg(y);
}
I'm not really surprised that it can't handle literals, since it would have to
create extra space on the stack, and pass its reference to the function:
(gdb) p const_ref_arg(0)
Attempt to take address of value not located in memory.
But I did think it would work with an existing variable:
(gdb) p const_ref_arg(y)
Attempt to take address of value not located in memory.
It works with the non-const variant:
(gdb) p ref_arg(y)
$1 = 0
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-05-12 13:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-09 11:32 [Bug c++/25957] New: Unable to call std::map::operator[] from gdb jengelh at inai dot de
2020-05-12 13:07 ` [Bug c++/25957] " ssbssa at sourceware dot org
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).