This is the mail archive of the
gdb-prs@sourceware.org
mailing list for the GDB project.
[Bug c++/11627] New: No access to automatic variables in constructors and destructors
- From: "thor at math dot tu-berlin dot de" <sourceware-bugzilla at sourceware dot org>
- To: gdb-prs at sourceware dot org
- Date: 24 May 2010 13:47:13 -0000
- Subject: [Bug c++/11627] New: No access to automatic variables in constructors and destructors
- Reply-to: sourceware-bugzilla at sourceware dot org
gdb cannot access automatic ("local") variables in C++ constructors and
destructors. To reproduce, enter the following program:
class A {
//
int var;
public:
A(int value);
~A(void);
//
int getVar()
{
return var;
}
};
A::A(int value)
{
int tmp = value;
while(tmp & 1) {
tmp += value;
tmp >>= 1;
value >>= 1;
}
var = value;
}
A::~A(void)
{
int tmp = var;
while(tmp > 0) {
tmp--;
}
}
int main(int argc,char **argv)
{
int i;
A a(42);
return a.getVar();
}
compile with -O0 -ggdb3 with g++ 4.3.2 and start debugging with gdb. Set a
breakpoint at main, step into A::A. "print tmp" will only give you
No symbol "tmp" in current context.
which is clearly incorrect. Continue stepping through the program. When entering
the destructor, try the same again. Again "tmp" is not accessible.
Note that this is not because the compiler optimized the variable out, this can
be checked on the generated assembly source.
--
Summary: No access to automatic variables in constructors and
destructors
Product: gdb
Version: 7.1
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at sourceware dot org
ReportedBy: thor at math dot tu-berlin dot de
CC: gdb-prs at sourceware dot org
GCC build triplet: x86_64-unknown-linux-gnu
GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu
http://sourceware.org/bugzilla/show_bug.cgi?id=11627
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.