W
wenmang
Here is the code which causes core dump when is built differently, 1
for regular dev built, the other for packaging build.
class my_class{
public:
my_class(){};
~my_class(){};
private:
string myData1;
string myData2;
};
x.C file:
my_class::my_class() : myData1(), myData2()
{
}
my_class::~my_class()
{
}
Obviously, ctor/dtor are defined twice in .h and .C files. Here is my
question:
1. are myData1 and myData2 are initialized or not when ctor/dtor
defined in .h are called?
2. What behaviour of compiler if ctor/dtor are defined twice?
3. debug trace indicates that one of two strings are not initialized,
here is debug output:
debug> p myData1
{
_String_base::_M_start=NULL
_String_base::_M_finish=NULL
_String_base::_M_end_of_storage=NULL
static basic_string::npos=4294967295
}
Can I safely say that myData1 memory is not allocated at this point, if
string assignment happens, it will lead core-dump, right?
Thx.
for regular dev built, the other for packaging build.
class my_class{
public:
my_class(){};
~my_class(){};
private:
string myData1;
string myData2;
};
x.C file:
my_class::my_class() : myData1(), myData2()
{
}
my_class::~my_class()
{
}
Obviously, ctor/dtor are defined twice in .h and .C files. Here is my
question:
1. are myData1 and myData2 are initialized or not when ctor/dtor
defined in .h are called?
2. What behaviour of compiler if ctor/dtor are defined twice?
3. debug trace indicates that one of two strings are not initialized,
here is debug output:
debug> p myData1
{
_String_base::_M_start=NULL
_String_base::_M_finish=NULL
_String_base::_M_end_of_storage=NULL
static basic_string::npos=4294967295
}
Can I safely say that myData1 memory is not allocated at this point, if
string assignment happens, it will lead core-dump, right?
Thx.