c++/1234: local variables in destructor ignored

mvanier@cs.caltech.edu mvanier@cs.caltech.edu
Wed Jun 4 04:08:00 GMT 2003


>Number:         1234
>Category:       c++
>Synopsis:       local variables in destructor ignored
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Wed Jun 04 04:08:01 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Michael Vanier
>Release:        gdb 5.3
>Organization:
>Environment:
Debian Linux, 2.4.17 kernel, g++ 3.3
>Description:
Gdb does not recognize local variables within a destructor, making it impossible to examine their values.  In the code snippet below, setting a breakpoint in the destructor Test::~Test() allows me to step through the destructor code, but I can't print the value of "t" because gdb says that there is no such variable in the current context.  When I do "info locals" gdb asserts that there are no locals.
>How-To-Repeat:
class Test {
private:
    int *data;
public:
    Test();
   ~Test();
};

Test::Test() {
    data = new int[1000];
}

Test::~Test() {
    int *t = data;
    delete [] t;
}


int main() {
    Test s;

    return 0;
}

>Fix:
None.
>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gdb-prs mailing list