Bug 12106 - x.bar is 1, but "p x.bar" says x.bar is -147973464
Summary: x.bar is 1, but "p x.bar" says x.bar is -147973464
Status: RESOLVED DUPLICATE of bug 11836
Alias: None
Product: gdb
Classification: Unclassified
Component: c++ (show other bugs)
Version: 7.2
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Depends on:
Reported: 2010-10-09 22:35 UTC by Askar Safin
Modified: 2010-10-11 22:09 UTC (History)
1 user (show)

See Also:
Last reconfirmed:


Note You need to log in before you can comment on or make changes to this bug.
Description Askar Safin 2010-10-09 22:35:08 UTC
I created x.cpp:

class foo
	int bar;

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

int main()

Then I compiled this and start gdb:

# g++ -g x.cpp
# gdb a.out
GNU gdb (GDB)
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:
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 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 ***