Bug 12106

Summary: x.bar is 1, but "p x.bar" says x.bar is -147973464
Product: gdb Reporter: Askar Safin <safinaskar>
Component: c++Assignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED DUPLICATE    
Severity: normal CC: tromey
Priority: P2    
Version: 7.2   
Target Milestone: ---   
Host: Target:
Build: Last reconfirmed:

Description Askar Safin 2010-10-09 22:35:08 UTC
I created x.cpp:

class foo
{
public:
	int bar;
	~foo(){};
};

foo f()
{
	foo x;
	x.bar = 1;
	x.bar = x.bar;
	return x;
};

int main()
{
	f();
};

Then I compiled this and start gdb:

# g++ -g x.cpp
# gdb a.out
GNU gdb (GDB) 7.2.50.20101009
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /root/Desktop/a.out...done.
(gdb) br x.cpp:11
Breakpoint 1 at 0x40058b: file x.cpp, line 11.
(gdb) r
Starting program: /root/Desktop/a.out 

Breakpoint 1, f () at x.cpp:11
11              x.bar = 1;
(gdb) n
12              x.bar = x.bar;
(gdb) p x.bar
$1 = -147973464

I use Debian Squeeze GNU/Linux, linux kernel 2.6.32-5, amd64, gcc and g++ 4:4.4.4-2 from my repository

This bug was when I used gdb 7.0.1-2+b1 from my repository and when I used gdb 7.2.50.20101009 from ftp://sourceware.org/pub/gdb/snapshots/, too.

I'm Russian. So please speak with me in Russian or simple English.
Comment 1 Tom Tromey 2010-10-11 22:09:20 UTC
This is a g++ bug.  Closing as dup of the gdb tracker.

*** This bug has been marked as a duplicate of bug 11836 ***