From: Charles Davis Subject: [PATCH] kernel32/tests: Use a volatile pointer to cause a crash in the debugger tests. (Clang) Message-Id: <1442959925-40854-1-git-send-email-cdavis5x@gmail.com> Date: Tue, 22 Sep 2015 16:12:05 -0600 Dereferencing a null pointer is undefined behavior according to the C standard. If Clang can prove that a pointer dereference will always be null, it will replace it with a 'ud2' instruction. This still triggers a crash, but with the wrong exception (STATUS_INVALID_OPCODE instead of STATUS_ACCESS_VIOLATION). Making the pointer volatile inhibits this optimization, causing the program to die with the correct exception. Signed-off-by: Charles Davis --- dlls/kernel32/tests/debugger.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/kernel32/tests/debugger.c b/dlls/kernel32/tests/debugger.c index a802784..326a903 100644 --- a/dlls/kernel32/tests/debugger.c +++ b/dlls/kernel32/tests/debugger.c @@ -158,7 +158,7 @@ typedef struct static void doCrash(int argc, char** argv) { - char* p; + volatile char* p; /* make sure the exception gets to the debugger */ SetErrorMode( 0 ); -- 2.5.3