GDB crashes when call member function having same name as a local pointer variable

Neo cjia@cse.unl.edu
Fri Feb 2 19:14:00 GMT 2007


hi,

I am wondering if it would be a bug. The following is the tiny program I 
am using to test. This test failed on both gdb 6.5 and 6.6

=========================
#include <stdio.h>

class foo {
  private:
    int _data;
  public:
    int data() { return _data; }
    void bar();
};

void
foo::bar()
{
  char * data = NULL;
  printf("Can you do p data()?\n");   // When let gdb breaks on this 
statement, "p data()" will cause segmentation fault.
}

int main(int argc, char ** argv)
{
  foo obj;
  obj.bar();
  return 0;
}
===================
Do we need to provide some hints to the user such as popping up 
"this->data()" ?

Thanks,
Neo

-- 
I would remember that if researchers were not ambitious
probably today we haven't the technology we are using!



More information about the Gdb mailing list