问题描述
- Debug Assertion failed! 编译提示出错
-
当程序编译时的出错信息提示:
Debug Assertion failed!
Program: D:rgribintest.exe
File:afxcoll.inl
Line:376在调试时的出错提示:
First-chance exception in al.exe (MFC42D.DLL): 0xC0000005: Access Violation.
First-chance exception in al.exe (MFC42D.DLL): 0xC0000005: Access Violation.
Unhandled exception in al.exe(MFC42D.DLL):0Xc0000005:AccessViolation堆栈的出错提示信息:
CStringList::GetHead() line 376 + 38 bytes
AL! 0040fae1()
AL! 00414505()
AL! 0040dcb8()
AL! 0040df16()
AfxDlgProc(HWND__ * 0x000302f8, unsigned int 272, unsigned int 203712, unsigned int 203712) line 35 + 14 bytes
USER32! 773186ef()
USER32! 77309eb2()
USER32! 7730b98b()
USER32! 773290f9()
USER32! 773186ef()
USER32! 77318876()
USER32! 773143cf()
USER32! 773341f9()
CWnd::DefWindowProcA(unsigned int 272, unsigned int 203712, long 0) line 1000 + 32 bytes
CWnd::Default() line 249
CDialog::HandleInitDialog(unsigned int 203712, unsigned int 203712) line 621 + 8 bytes
CWnd::OnWndMsg(unsigned int 272, unsigned int 203712, long 0, long * 0x0012ec38) line 1815 + 17 bytes
CWnd::WindowProc(unsigned int 272, unsigned int 203712, long 0) line 1585 + 30 bytes
AfxCallWndProc(CWnd * 0x0012f004 {CWnd hWnd=0x000302f8}, HWND__ * 0x000302f8, unsigned int 272, unsigned int 203712, long 0) line 215 + 26 bytes
AfxWndProc(HWND__ * 0x000302f8, unsigned int 272, unsigned int 203712, long 0) line 368
AfxWndProcBase(HWND__ * 0x000302f8, unsigned int 272, unsigned int 203712, long 0) line 220 + 21 bytes
USER32! 773186ef()
USER32! 77318876()
USER32! 77317631()请帮帮,谢谢
解决方案
这种错误一般是操作越界了,看代码分析
解决方案二:
直接编译器调试。多看指针操作
解决方案三:
这不是编译错误,而是运行时错误。多半是指针越界造成的。如果你用的是VS,用F5调试方式运行,出错的时候可以转到出错的代码行上,然后仔细检查那一行有没有指针的问题。
解决方案四:
三位高手,谢谢了,怎样检查指针越界,我已经知道出错的地方是在这里,但不知道怎样改:
for(int i=0;i
{
** this->m_listctrl->InsertColumn(i,m_strlist[i].GetHead());** 到这里出错,即错在GetHead()这里
col_length[i]=max(col_length[i],m_strlist[i].GetHead().GetLength());
POSITION pos=m_strlist[i].FindIndex(1);
for(int j=1;pos!=NULL;j++)
{
str=m_strlist[i].GetNext(pos);
col_length[i]=max(col_length[i],str.GetLength());
}
m_listctrl->SetColumnWidth(i,col_length[i]*10);//LVSCW_AUTOSIZE_USEHEADER
}
GetHead() 在这个函数的堆栈出错提示是:
CStringList::GetHead() line 376 + 38 bytes
AL! 0040fae1()
AL! 00414505()
AL! 0040dcb8()
AL! 0040df16()
AfxDlgProc(HWND__ * 0x00021c20, unsigned int 272, unsigned int 201048, unsigned int 201048) line 35 + 14 bytes
USER32! 754b86ef()
USER32! 754a9eb2()
USER32! 754ab98b()
USER32! 754c90f9()
USER32! 754b86ef()
USER32! 754b8876()
USER32! 754b43cf()
USER32! 754d41f9()
CWnd::DefWindowProcA(unsigned int 272, unsigned int 201048, long 0) line 1000 + 32 bytes
CWnd::Default() line 249
怎样解决,谢谢
解决方案五:
m_strlist[i]这里能不能取到值,i是多少?strList最大有多少