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; 14+ 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] 14+ 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; 14+ 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] 14+ 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; 14+ 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] 14+ 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; 14+ 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] 14+ 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; 14+ 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] 14+ messages in thread

* [Bug c++/11836] gdb cannot access variables that are subject to return value optimization
       [not found] <bug-11836-4717@http.sourceware.org/bugzilla/>
                   ` (7 preceding siblings ...)
  2014-02-16 18:24 ` jackie.rosen at hushmail dot com
@ 2014-05-28 19:43 ` schwab at sourceware dot org
  8 siblings, 0 replies; 14+ messages in thread
From: schwab at sourceware dot org @ 2014-05-28 19:43 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=11836

Andreas Schwab <schwab at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|jackie.rosen at hushmail dot com   |

-- 
You are receiving this mail because:
You are on the CC list for the bug.


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

* [Bug c++/11836] gdb cannot access variables that are subject to return value optimization
       [not found] <bug-11836-4717@http.sourceware.org/bugzilla/>
                   ` (6 preceding siblings ...)
  2011-02-17 17:29 ` jan.kratochvil at redhat dot com
@ 2014-02-16 18:24 ` jackie.rosen at hushmail dot com
  2014-05-28 19:43 ` schwab at sourceware dot org
  8 siblings, 0 replies; 14+ messages in thread
From: jackie.rosen at hushmail dot com @ 2014-02-16 18:24 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=11836

Jackie Rosen <jackie.rosen at hushmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jackie.rosen at hushmail dot com

--- Comment #11 from Jackie Rosen <jackie.rosen at hushmail dot com> ---
*** Bug 260998 has been marked as a duplicate of this bug. ***
Seen from the domain http://volichat.com
Page where seen: http://volichat.com/adult-chat-rooms
Marked for reference. Resolved as fixed @bugzilla.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


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

* [Bug c++/11836] gdb cannot access variables that are subject to return value optimization
       [not found] <bug-11836-4717@http.sourceware.org/bugzilla/>
                   ` (5 preceding siblings ...)
  2011-02-17 17:15 ` rdengler at arcor dot de
@ 2011-02-17 17:29 ` jan.kratochvil at redhat dot com
  2014-02-16 18:24 ` jackie.rosen at hushmail dot com
  2014-05-28 19:43 ` schwab at sourceware dot org
  8 siblings, 0 replies; 14+ messages in thread
From: jan.kratochvil at redhat dot com @ 2011-02-17 17:29 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=11836

Jan Kratochvil <jan.kratochvil at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |RESOLVED
         Resolution|                            |INVALID

--- Comment #10 from Jan Kratochvil <jan.kratochvil at redhat dot com> 2011-02-17 17:28:43 UTC ---
So let's say it has never been a GDB bug.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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

* [Bug c++/11836] gdb cannot access variables that are subject to return value optimization
       [not found] <bug-11836-4717@http.sourceware.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2011-02-14 12:34 ` jan.kratochvil at redhat dot com
@ 2011-02-17 17:15 ` rdengler at arcor dot de
  2011-02-17 17:29 ` jan.kratochvil at redhat dot com
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: rdengler at arcor dot de @ 2011-02-17 17:15 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=11836

--- Comment #9 from rdengler at arcor dot de 2011-02-17 17:14:59 UTC ---
Hi Jan,

thanks for the information.
Sorry I couldn't test it yet, there only is g++ 4.4.3
on my system.
I suppose the confusing behaviour will have gone,
the test code is simple enough.

Regards
Richard



jan.kratochvil at redhat dot com schrieb:

>http://sourceware.org/bugzilla/show_bug.cgi?id=11836
>
>Jan Kratochvil <jan.kratochvil at redhat dot com> changed:
>
>           What    |Removed                     |Added
>----------------------------------------------------------------------------
>             Status|NEW                         |WAITING
>                 CC|                            |jan.kratochvil at redhat
>                   |                            |dot com
>
>--- Comment #8 from Jan Kratochvil <jan.kratochvil at redhat dot com> 2011-02-14 12:34:01 UTC ---
>http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44367
>
>Breakpoint 1, foo () at rvo.C:8
>8        return s;
>$1 = "helloworld"
>
>Breakpoint 2, bar () at rvo.C:16
>16        return "something else";
>$2 = "helloworld"
>
>with /r:
>
>Breakpoint 1, foo () at rvo.C:8
>8        return s;
>$1 = {static npos = 18446744073709551615, _M_dataplus = {<std::allocator<char>>
>= {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>}, 
>    _M_p = 0x601058 "helloworld"}}
>
>Breakpoint 2, bar () at rvo.C:16
>16        return "something else";
>$2 = {static npos = 18446744073709551615, _M_dataplus = {<std::allocator<char>>
>= {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>}, 
>    _M_p = 0x601028 "helloworld"}}
>
>This should be a GCC-only bug which is already fixed:
>FAIL g++ (GCC) 4.4.6 20110124 (prerelease)
>PASS g++ (GCC) 4.5.3 20110124 (prerelease)
>PASS g++ (GCC) 4.6.0 20110212 (experimental)
>PASS gcc-c++-4.6.0-0.6.fc15.x86_64
>
>Behaves the same with both:
>GNU gdb (GDB) 7.2.50.20110213-cvs
>gdb-7.2.50.20110206-18.fc15.x86_64
>
>Is the bug still reproducible with recent GCC?
>
>  
>

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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

* [Bug c++/11836] gdb cannot access variables that are subject to return value optimization
       [not found] <bug-11836-4717@http.sourceware.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2010-10-12 16:21 ` safinaskar at mail dot ru
@ 2011-02-14 12:34 ` jan.kratochvil at redhat dot com
  2011-02-17 17:15 ` rdengler at arcor dot de
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: jan.kratochvil at redhat dot com @ 2011-02-14 12:34 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=11836

Jan Kratochvil <jan.kratochvil at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |WAITING
                 CC|                            |jan.kratochvil at redhat
                   |                            |dot com

--- Comment #8 from Jan Kratochvil <jan.kratochvil at redhat dot com> 2011-02-14 12:34:01 UTC ---
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44367

Breakpoint 1, foo () at rvo.C:8
8        return s;
$1 = "helloworld"

Breakpoint 2, bar () at rvo.C:16
16        return "something else";
$2 = "helloworld"

with /r:

Breakpoint 1, foo () at rvo.C:8
8        return s;
$1 = {static npos = 18446744073709551615, _M_dataplus = {<std::allocator<char>>
= {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>}, 
    _M_p = 0x601058 "helloworld"}}

Breakpoint 2, bar () at rvo.C:16
16        return "something else";
$2 = {static npos = 18446744073709551615, _M_dataplus = {<std::allocator<char>>
= {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>}, 
    _M_p = 0x601028 "helloworld"}}

This should be a GCC-only bug which is already fixed:
FAIL g++ (GCC) 4.4.6 20110124 (prerelease)
PASS g++ (GCC) 4.5.3 20110124 (prerelease)
PASS g++ (GCC) 4.6.0 20110212 (experimental)
PASS gcc-c++-4.6.0-0.6.fc15.x86_64

Behaves the same with both:
GNU gdb (GDB) 7.2.50.20110213-cvs
gdb-7.2.50.20110206-18.fc15.x86_64

Is the bug still reproducible with recent GCC?

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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

* [Bug c++/11836] gdb cannot access variables that are subject to return value optimization
       [not found] <bug-11836-4717@http.sourceware.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2010-10-11 22:14 ` tromey at redhat dot com
@ 2010-10-12 16:21 ` safinaskar at mail dot ru
  2011-02-14 12:34 ` jan.kratochvil at redhat dot com
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: safinaskar at mail dot ru @ 2010-10-12 16:21 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=11836

Askar Safin <safinaskar at mail dot ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|safinaskar at mail dot ru   |

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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

* [Bug c++/11836] gdb cannot access variables that are subject to return value optimization
       [not found] <bug-11836-4717@http.sourceware.org/bugzilla/>
  2010-10-11 22:10 ` tromey at redhat dot com
  2010-10-11 22:13 ` tromey at redhat dot com
@ 2010-10-11 22:14 ` tromey at redhat dot com
  2010-10-12 16:21 ` safinaskar at mail dot ru
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: tromey at redhat dot com @ 2010-10-11 22:14 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=11836

Tom Tromey <tromey at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |cmayer at xp8 dot de

--- Comment #7 from Tom Tromey <tromey at redhat dot com> 2010-10-11 22:13:52 UTC ---
*** Bug 9607 has been marked as a duplicate of this bug. ***

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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

* [Bug c++/11836] gdb cannot access variables that are subject to return value optimization
       [not found] <bug-11836-4717@http.sourceware.org/bugzilla/>
  2010-10-11 22:10 ` tromey at redhat dot com
@ 2010-10-11 22:13 ` tromey at redhat dot com
  2010-10-11 22:14 ` tromey at redhat dot com
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: tromey at redhat dot com @ 2010-10-11 22:13 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=11836

Tom Tromey <tromey at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rdengler at arcor dot de

--- Comment #6 from Tom Tromey <tromey at redhat dot com> 2010-10-11 22:13:08 UTC ---
*** Bug 9640 has been marked as a duplicate of this bug. ***

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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

* [Bug c++/11836] gdb cannot access variables that are subject to return value optimization
       [not found] <bug-11836-4717@http.sourceware.org/bugzilla/>
@ 2010-10-11 22:10 ` tromey at redhat dot com
  2010-10-11 22:13 ` tromey at redhat dot com
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: tromey at redhat dot com @ 2010-10-11 22:10 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=11836

Tom Tromey <tromey at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |safinaskar at mail dot ru

--- Comment #5 from Tom Tromey <tromey at redhat dot com> 2010-10-11 22:09:20 UTC ---
*** Bug 12106 has been marked as a duplicate of this bug. ***

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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

end of thread, other threads:[~2014-05-28 19:43 UTC | newest]

Thread overview: 14+ 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
     [not found] <bug-11836-4717@http.sourceware.org/bugzilla/>
2010-10-11 22:10 ` tromey at redhat dot com
2010-10-11 22:13 ` tromey at redhat dot com
2010-10-11 22:14 ` tromey at redhat dot com
2010-10-12 16:21 ` safinaskar at mail dot ru
2011-02-14 12:34 ` jan.kratochvil at redhat dot com
2011-02-17 17:15 ` rdengler at arcor dot de
2011-02-17 17:29 ` jan.kratochvil at redhat dot com
2014-02-16 18:24 ` jackie.rosen at hushmail dot com
2014-05-28 19:43 ` schwab 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).