From 5e4214cee4f74d25f1d89dc1c95dc247ed20b6c8 Mon Sep 17 00:00:00 2001 From: "zhanyong.wan" Date: Thu, 8 Jul 2010 21:44:59 +0000 Subject: [PATCH] Makes gtest_break_on_failure_unittest work on minGW (by vladl); improves the NULL-dereferencing hack to work with LLVM (by chandlerc). --- src/gtest.cc | 6 +++++- test/gtest_break_on_failure_unittest_.cc | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/gtest.cc b/src/gtest.cc index cb2c34c7..9855f53d 100644 --- a/src/gtest.cc +++ b/src/gtest.cc @@ -3608,7 +3608,11 @@ void UnitTest::AddTestPartResult(TestPartResult::Type result_type, // the --gtest_catch_exceptions flags are specified. DebugBreak(); #else - *static_cast(NULL) = 1; + // Dereference NULL through a volatile pointer to prevent the compiler + // from removing. We use this rather than abort() or __builtin_trap() for + // portability: Symbian doesn't implement abort() well, and some debuggers + // don't correctly trap abort(). + *static_cast(NULL) = 1; #endif // GTEST_OS_WINDOWS } else if (GTEST_FLAG(throw_on_failure)) { #if GTEST_HAS_EXCEPTIONS diff --git a/test/gtest_break_on_failure_unittest_.cc b/test/gtest_break_on_failure_unittest_.cc index d28d1d3d..6779c903 100644 --- a/test/gtest_break_on_failure_unittest_.cc +++ b/test/gtest_break_on_failure_unittest_.cc @@ -69,7 +69,7 @@ int main(int argc, char **argv) { // a general protection fault (segment violation). SetErrorMode(SEM_NOGPFAULTERRORBOX | SEM_FAILCRITICALERRORS); -#if !GTEST_OS_WINDOWS_MOBILE +#if GTEST_HAS_SEH && !GTEST_OS_WINDOWS_MOBILE // The default unhandled exception filter does not always exit // with the exception code as exit code - for example it exits with // 0 for EXCEPTION_ACCESS_VIOLATION and 1 for EXCEPTION_BREAKPOINT