I have a class named Sample
which contains a parameter value
which is of type std::string
.
There is a public member function setValue(std::string tempdata)
which is used to set the value of this member.
void Sample::setValue( std::string tempdata ) { this->value= tempdata; }
From the application I have to set the value of this parameter. I do something like:
std::string tempvalue = "Hello";
Sample s;
s.setValue( tempvalue );
when I run the application the program crashes and on debugging it through gdb I get:
#0 0x049da761 in __gnu_cxx::__exchange_and_add () from /usr/lib/libstdc++.so.6
#1 0x049c0e6e in std::string::assign () from /usr/lib/libstdc++.so.6
#2 0x049c0ed1 in std::string::operator= () from /usr/lib/libstdc++.so.6
#3 0x08075e9b in Sample::setValue (this=0x83779a8, tempdata=Cannot access memory at address 0xffffffff )
Can anyone please suggest how should I go about debugging this issue?