public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/11836] New: gdb cannot access variables that are subject to return value optimization
@ 2010-07-23 10:47 andre dot poenitz at nokia dot com
2010-07-23 10:48 ` [Bug c++/11836] " andre dot poenitz at nokia dot com
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: andre dot poenitz at nokia dot com @ 2010-07-23 10:47 UTC (permalink / raw)
To: gdb-prs
#include <string>
std::string foo()
{
std::string s;
s = "hello";
s += "world";
return s;
}
std::string bar()
{
std::string s;
s = "hello";
s += "world";
return "something else";
}
int main()
{
int a = foo().size();
int b = bar().size();
return a + b;
}
/*
Gcc seems to apply return value optimization (even at -O0) but there is
some problem with either the generated debug information or the way
gdb handles it.
To reproduce it, save this file here as rvo.cpp and run
g++ -g -O0 rvo.cpp -o rvo
gdb -ex 'set confirm off' -ex 'file ./rvo' \
-ex 'b rvo.cpp:8' -ex 'b rvo.cpp:16' \
-ex 'run' -ex 'print s' \
-ex 'cont' -ex 'print s' \
-ex 'quit'
The result will look like:
Breakpoint 1, foo () at rvo.cpp:8
8 s += "world";
$1 = {static npos = <optimized out>,
_M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>>
= {<No daa fields>}, <No data fields>}, _M_p = 0x1 <Address 0x1 out of
bounds>}}
Breakpoint 2, bar () at rvo.cpp:16
16 s += "world";
$2 = {static npos = <optimized out>,
_M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>>
= {<No data fields>}, <No data fields>}, _M_p = 0x804b014 "hello"}}
Program exited with code 030.
RVO seems to be applied in the first case with "dangling" debug information.
If no RVO is used (second case), all is fine.
*/
--
Summary: gdb cannot access variables that are subject to return
value optimization
Product: gdb
Version: 7.1
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at sourceware dot org
ReportedBy: andre dot poenitz at nokia dot com
CC: gdb-prs at sourceware dot org
GCC build triplet: i486-linux-gnu
GCC host triplet: i486-linux-gnu
GCC target triplet: i486-linux-gnu
http://sourceware.org/bugzilla/show_bug.cgi?id=11836
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/11836] gdb cannot access variables that are subject to return value optimization
2010-07-23 10:47 [Bug c++/11836] New: gdb cannot access variables that are subject to return value optimization andre dot poenitz at nokia dot com
@ 2010-07-23 10:48 ` andre dot poenitz at nokia dot com
2010-07-23 14:54 ` swagiaal at redhat dot com
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: andre dot poenitz at nokia dot com @ 2010-07-23 10:48 UTC (permalink / raw)
To: gdb-prs
------- Additional Comments From andre dot poenitz at nokia dot com 2010-07-23 10:48 -------
Created an attachment (id=4882)
--> (http://sourceware.org/bugzilla/attachment.cgi?id=4882&action=view)
Test code and build instructions
--
http://sourceware.org/bugzilla/show_bug.cgi?id=11836
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/11836] gdb cannot access variables that are subject to return value optimization
2010-07-23 10:47 [Bug c++/11836] New: gdb cannot access variables that are subject to return value optimization andre dot poenitz at nokia dot com
2010-07-23 10:48 ` [Bug c++/11836] " andre dot poenitz at nokia dot com
@ 2010-07-23 14:54 ` swagiaal at redhat dot com
2010-07-23 16:43 ` andre dot poenitz at nokia dot com
2010-07-23 16:46 ` tromey at redhat dot com
3 siblings, 0 replies; 5+ messages in thread
From: swagiaal at redhat dot com @ 2010-07-23 14:54 UTC (permalink / raw)
To: gdb-prs
------- Additional Comments From swagiaal at redhat dot com 2010-07-23 14:54 -------
Andre,
Thanks for the nice test case. 's' seems to have a location in the debug info
but it is either wrong or gdb is reading it wrong. I'll take a look at this when
I get a chance. If anyone else is interested, in the mean while, go for it :)
Sami
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |swagiaal at redhat dot com
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
http://sourceware.org/bugzilla/show_bug.cgi?id=11836
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/11836] gdb cannot access variables that are subject to return value optimization
2010-07-23 10:47 [Bug c++/11836] New: gdb cannot access variables that are subject to return value optimization andre dot poenitz at nokia dot com
2010-07-23 10:48 ` [Bug c++/11836] " andre dot poenitz at nokia dot com
2010-07-23 14:54 ` swagiaal at redhat dot com
@ 2010-07-23 16:43 ` andre dot poenitz at nokia dot com
2010-07-23 16:46 ` tromey at redhat dot com
3 siblings, 0 replies; 5+ messages in thread
From: andre dot poenitz at nokia dot com @ 2010-07-23 16:43 UTC (permalink / raw)
To: gdb-prs
------- Additional Comments From andre dot poenitz at nokia dot com 2010-07-23 16:43 -------
It turns out it is known on the gcc side:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44731
--
http://sourceware.org/bugzilla/show_bug.cgi?id=11836
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/11836] gdb cannot access variables that are subject to return value optimization
2010-07-23 10:47 [Bug c++/11836] New: gdb cannot access variables that are subject to return value optimization andre dot poenitz at nokia dot com
` (2 preceding siblings ...)
2010-07-23 16:43 ` andre dot poenitz at nokia dot com
@ 2010-07-23 16:46 ` tromey at redhat dot com
3 siblings, 0 replies; 5+ messages in thread
From: tromey at redhat dot com @ 2010-07-23 16:46 UTC (permalink / raw)
To: gdb-prs
------- Additional Comments From tromey at redhat dot com 2010-07-23 16:46 -------
Possibly this gcc bug:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44731
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |tromey at redhat dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=11836
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-07-23 16:46 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-23 10:47 [Bug c++/11836] New: gdb cannot access variables that are subject to return value optimization andre dot poenitz at nokia dot com
2010-07-23 10:48 ` [Bug c++/11836] " andre dot poenitz at nokia dot com
2010-07-23 14:54 ` swagiaal at redhat dot com
2010-07-23 16:43 ` andre dot poenitz at nokia dot com
2010-07-23 16:46 ` tromey at redhat dot com
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).