This is the mail archive of the
gdb-prs@sources.redhat.com
mailing list for the GDB project.
c++/1147: segfault dereferencing a reference to a pointer
- From: kraftche at cae dot wisc dot edu
- To: gdb-gnats at sources dot redhat dot com
- Date: 19 Mar 2003 19:32:15 -0000
- Subject: c++/1147: segfault dereferencing a reference to a pointer
- Reply-to: kraftche at cae dot wisc dot edu
>Number: 1147
>Category: c++
>Synopsis: segfault dereferencing a reference to a pointer
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Mar 19 19:38:02 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: kraftche at cae dot wisc dot edu
>Release: 5.3
>Organization:
>Environment:
linux, gcc 2.95.4
>Description:
gdb passes bad "this" pointer to a class method called
through a reference to a poitner.
>How-To-Repeat:
#!/bin/bash
file=gdb-ref2.cpp
cat > $file <<ENDOFSOURCE
#include <iostream>
class Integer {
public:
Integer(int i = 0 ) : value(i) {}
void print() const { std::cout << value << std::endl; }
private:
int value;
};
void make_positive_integer( int value, Integer*& result )
{
result = 0;
if ( value >= 0 )
result = new Integer(value);
if ( result )
result->print();
}
int main()
{
Integer *int1;
make_positive_integer( 5, int1 );
return 0;
}
ENDOFSOURCE
g++ -g $file -o ${file}.x
gdb ${file}.x <<ENDOFGDB
b 17
r
p *result
call result->print()
ENDOFGDB
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: