This is the mail archive of the
gdb-prs@sources.redhat.com
mailing list for the GDB project.
gdb/1292: GNU/Linux, GCC 3.2, C++, call a function in the program
- From: sonal dot santan at xilinx dot com
- To: gdb-gnats at sources dot redhat dot com
- Date: 21 Jul 2003 20:59:46 -0000
- Subject: gdb/1292: GNU/Linux, GCC 3.2, C++, call a function in the program
- Reply-to: sonal dot santan at xilinx dot com
>Number: 1292
>Category: gdb
>Synopsis: GNU/Linux, GCC 3.2, C++, call a function in the program
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Mon Jul 21 21:08:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: sonal.santan@xilinx.com
>Release: GNU gdb 5.3
>Organization:
>Environment:
uname -v : "Linux cumin 2.4.7-10smp #1 SMP Thu Sep 6 17:09:31 EDT 2001 i686 unknown"
gcc -v : "Reading specs from /products/gcc3.2/lib/gcc-lib/i686-pc-linux-gnu/3.2/specs
Configured with: ../gcc-3.2/configure --prefix=/products/gcc3.2 --enable-languages=c,c++
Thread model: posix
gcc version 3.2"
GDB configuration : "i686-pc-linux-gnu"
>Description:
If a C++ method requires an argument to be passed by value, and user calls that method on the gdb prompt by using the 'call' command, gdb does not invoke the copy constructor on the actual correctly, resulting in the garbage value being passed to the called method.
>How-To-Repeat:
g++ -g gdbbug.cpp
gdb a.out
break main
n
n
call xyz(ins)
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="gdbbug.cpp"
Content-Disposition: inline; filename="gdbbug.cpp"
#include <iostream>
#include <string>
class pq {
char * x;
std::string s;
public:
pq(char *ax, const char * as) : x(ax), s(as) {}
pq(char *ax, std::string & as) : x(ax), s(as) {}
pq(const pq & apq) : x(apq.x), s(apq.s) {}
void crashmethod() const;
};
void pq::crashmethod() const
{
std::cout << x << std::endl;
std::cout << s << std::endl;
}
void xyz(pq apq)
{
apq.crashmethod();
}
int main(int argc, char * argv[])
{
pq ins("sonal", "raja");
xyz(ins);
return 0; // At this line issue "call xyz(ins)" at debugger prompt
}