为什么执行无效指令不会终止我的程序? [英] Why executing invalid instruction does not terminate my program?
问题描述
我在VC ++中编程,我输入了无效的指令,例如
*(long *)0 = 0;
在我的对话框的窗口进程中.对于某些消息,例如VM_INITDIALOG,此指令将导致按预期在位置0X00000000写入访问冲突.但是在大多数消息(例如WM_PAINT等)中放置任何无效的指令并不会终止我的程序,这使我不会注意到程序中的错误.谁能告诉我这是为什么?
当我在32位平台上使用Windows XP和Windows Vista时,此问题并未解决.
我在Windows7 64bit上使用Visual Studio 2008 32bit,而我的硬件是HP笔记本DV6-2020EV
I program in VC++, I put an invalid instruction such as
*(long*)0=0;
In the window proc of my dialogs. for some messages such as VM_INITDIALOG this instruction causes an access violation writing at location 0X00000000 as expected. But putting any invalid instruction in most messages such as WM_PAINT,... does not terminate my program and this causes me not to notice bugs in my program. can anyone tell me why is this?
This problem did not accure when I used Windows XP and Windows Vista on 32bit platforms.
I use Visual Studio 2008 32bit on Windows7 64bit and my hardware is HP notebook DV6-2020EV
推荐答案
为什么不为此目的使用assert
?
:)
Why dont you useassert
for the purpose?
:)
这篇关于为什么执行无效指令不会终止我的程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!