From ca6a70c6082ff526b993c622d192c6d519800bc2 Mon Sep 17 00:00:00 2001 From: David Benjamin Date: Fri, 20 Jan 2017 12:54:07 -0500 Subject: [PATCH] Pass MSVC's C4826 warning. MSVC has an optional warning which flags when 32-bit pointers get cast into a 64-bit value. This is a little overaggressive I think, but to ease compiling in projects with aggressive warnings, fix this by just casting to const void * directly. Modern GCCs seem to compile it just fine. --- googletest/include/gtest/gtest-printers.h | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/googletest/include/gtest/gtest-printers.h b/googletest/include/gtest/gtest-printers.h index e850d605..c6f69fa1 100644 --- a/googletest/include/gtest/gtest-printers.h +++ b/googletest/include/gtest/gtest-printers.h @@ -426,13 +426,8 @@ void DefaultPrintTo(WrapPrinterType /* dummy */, *os << "NULL"; } else { // T is a function type, so '*os << p' doesn't do what we want - // (it just prints p as bool). We want to print p as a const - // void*. However, we cannot cast it to const void* directly, - // even using reinterpret_cast, as earlier versions of gcc - // (e.g. 3.4.5) cannot compile the cast when p is a function - // pointer. Casting to UInt64 first solves the problem. - *os << reinterpret_cast( - reinterpret_cast(p)); + // (it just prints p as bool). Cast p to const void* to print it. + *os << reinterpret_cast(p); } }