This is the mail archive of the
gdb-prs@sources.redhat.com
mailing list for the GDB project.
symtab/1619: Cannot call operator<<(ostream&, MyClass&) from gdb
- From: salman dot khilji at cae dot com
- To: gdb-gnats at sources dot redhat dot com
- Date: 23 Apr 2004 12:38:03 -0000
- Subject: symtab/1619: Cannot call operator<<(ostream&, MyClass&) from gdb
- Reply-to: salman dot khilji at cae dot com
>Number: 1619
>Category: symtab
>Synopsis: Cannot call operator<<(ostream&, MyClass&) from gdb
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Fri Apr 23 12:48:00 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator: salman.khilji@cae.com
>Release: 6.0
>Organization:
>Environment:
Linux, gcc 2.95.3
>Description:
I have a class which defines an operator<< so that it can be dumped to cout or cerr. I cannot call this function from gdb. I have searched the bug database and while this problem has been reported before and some solutions were presented, none of them worked using gdb 6.0, gcc 2.95.3
class MyClass
{
public:
int mInteger;
double mDouble;
};
ostream & operator<< (ostream & s, const MyClass & o)
{
s << o.mInteger << " " << o.mDouble << endl;
return s;
}
>How-To-Repeat:
Put a breakpoint on the attached file @ line 22. Then try to call the operator<< function defined on line 12.
compile with g++ -g -o test deleteme.cpp
>Fix:
Don't know.
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="deleteme.cpp"
Content-Disposition: inline; filename="deleteme.cpp"
#include <iostream>
using namespace std;
class MyClass
{
public:
int mInteger;
double mDouble;
};
ostream & operator<< (ostream & s, const MyClass & o)
{
s << o.mInteger << " " << o.mDouble << endl;
return s;
}
int
main()
{
MyClass obj;
cout << obj;
return 0;
}