变量++操作带来的core错误
该程序开发环境是linux下,使用gcc2.9.5。
使用gdb调试程序。
运行程序的时候,在一个程序还没有进入main函数的部分,
就出现了core错误。
程序体在一个header文件中。
#typedef unsigned long ULONG;
private:
ULONG m_length;
ULONG m_refCount;
UniteChar m_data[1];
public:
inline void AddRef()
{
if ( !isConst())
m_refCount++;
}
出错部分在m_refCount++;这一句,
#0 FJXML::SBaseManager::AddRef (this=0x82b2e54) at INC/UniteStringValue.h:187
187 m_refCount++;
在这一句往下执行就会有core dumped error.
这时,m_refCount的值0x80000003。
但假如在这句执行之前,使用如下两句语句,
gdb p m_refCount++;
gdb p m_refCount--;
程序就可以正确执行。
而假如在程序中添加这两句,又会出错。
请问一般出现这样的问题,大概会因为什么情况出现这样的问题。
请高手不吝赐教!